@cmmd-center/forge 0.10.12 → 0.10.13
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/bin.cjs +92 -25
- package/dist/bin.mjs +82 -15
- package/dist/client/assets/{CanvasPanel-mbL7UwXT.js → CanvasPanel-Cogtmutb.js} +2 -2
- package/dist/client/assets/{CompositeItem-Dm91tFrl.js → CompositeItem-D6h2WFmU.js} +2 -2
- package/dist/client/assets/{DiffPanel-Wf-m_tDJ.js → DiffPanel-DGiCJd76.js} +2 -2
- package/dist/client/assets/{DiffPanel.logic-Bvxf3m-9.js → DiffPanel.logic-Dd5YF6k3.js} +2 -2
- package/dist/client/assets/{DiffPanelShell-Cs-XLDgV.js → DiffPanelShell-C-nlQxal.js} +3 -3
- package/dist/client/assets/{DiffWorkerPoolProvider-KeQJ1rQG.js → DiffWorkerPoolProvider-CfmtkBLg.js} +2 -2
- package/dist/client/assets/{PullRequestCodePanel-BtdEznt0.js → PullRequestCodePanel-xkECqRzW.js} +2 -2
- package/dist/client/assets/{Virtualizer-C4HGxrvR.js → Virtualizer-CVyQexgp.js} +2 -2
- package/dist/client/assets/{canvasStateStore-CqQQvGP5.js → canvasStateStore-DUZyBLSv.js} +2 -2
- package/dist/client/assets/{cmmdAuthRedirect-Dm6mOZMB.js → cmmdAuthRedirect-Bkc6Luqb.js} +2 -2
- package/dist/client/assets/{index-DOFEIuQg.js → index-BD9iZwyM.js} +59 -59
- package/dist/client/assets/src-BlF9iHm-.js +3 -0
- package/dist/client/assets/{toggle-dld7kzOP.js → toggle-CWmPePti.js} +2 -2
- package/dist/client/assets/{useTriggerFocusGuards-DPZ1smix.js → useTriggerFocusGuards-O7DUCec0.js} +2 -2
- package/dist/client/index.html +10 -10
- package/dist/forge-build.json +1 -1
- package/package.json +1 -1
- package/dist/client/assets/src-BOr7-dep.js +0 -3
package/dist/bin.cjs
CHANGED
|
@@ -18674,16 +18674,81 @@ const CLAUDE_CODE_EFFORT_OPTIONS = [
|
|
|
18674
18674
|
const CODEX_DEFAULT_MODEL = "gpt-6-astra";
|
|
18675
18675
|
const CODEX_SPARK_MODEL = "gpt-5.3-codex-spark";
|
|
18676
18676
|
const CLAUDE_DEFAULT_MODEL = "claude-fable-5-1";
|
|
18677
|
-
|
|
18677
|
+
/**
|
|
18678
|
+
* Generic option value carried by ACP-based provider adapters (cursor, opencode).
|
|
18679
|
+
* Used to pass per-turn options like reasoning effort or thinking toggles to
|
|
18680
|
+
* the agent without baking them into model-specific schemas.
|
|
18681
|
+
*
|
|
18682
|
+
* Mirrors t3code's @t3tools/contracts ProviderOptionSelection — required by
|
|
18683
|
+
* the ported ACP runtime (apps/server/src/provider/acp/*) so cursor + opencode
|
|
18684
|
+
* adapters can carry user-selected reasoning levels through the session.
|
|
18685
|
+
*/
|
|
18686
|
+
const ProviderOptionSelectionValue = require_Schema$1.Union([TrimmedNonEmptyString, require_Schema$1.Boolean]);
|
|
18687
|
+
const ProviderOptionSelection = require_Schema$1.Struct({
|
|
18688
|
+
id: TrimmedNonEmptyString,
|
|
18689
|
+
value: ProviderOptionSelectionValue
|
|
18690
|
+
});
|
|
18691
|
+
/**
|
|
18692
|
+
* The object form on its own, exported so callers that need the individual
|
|
18693
|
+
* field schemas can reach them. The exported `CodexModelOptions` below is a
|
|
18694
|
+
* union and has no `.fields`.
|
|
18695
|
+
*/
|
|
18696
|
+
const CodexModelOptionsObject = require_Schema$1.Struct({
|
|
18678
18697
|
reasoningEffort: require_Schema$1.optional(require_Schema$1.Literals(CODEX_REASONING_EFFORT_OPTIONS)),
|
|
18679
18698
|
fastMode: require_Schema$1.optional(require_Schema$1.Boolean)
|
|
18680
18699
|
});
|
|
18681
|
-
|
|
18700
|
+
/** The object form on its own; see {@link CodexModelOptionsObject}. */
|
|
18701
|
+
const ClaudeModelOptionsObject = require_Schema$1.Struct({
|
|
18682
18702
|
thinking: require_Schema$1.optional(require_Schema$1.Boolean),
|
|
18683
18703
|
effort: require_Schema$1.optional(require_Schema$1.Literals(CLAUDE_CODE_EFFORT_OPTIONS)),
|
|
18684
18704
|
fastMode: require_Schema$1.optional(require_Schema$1.Boolean),
|
|
18685
18705
|
contextWindow: require_Schema$1.optional(require_Schema$1.String)
|
|
18686
18706
|
});
|
|
18707
|
+
/**
|
|
18708
|
+
* `[{ id, value }]` folded into `{ [id]: value }`.
|
|
18709
|
+
*
|
|
18710
|
+
* Duplicate ids keep the last, which is what an object literal would have done
|
|
18711
|
+
* had the sender used one.
|
|
18712
|
+
*/
|
|
18713
|
+
function selectionArrayToRecord(selections) {
|
|
18714
|
+
const record = {};
|
|
18715
|
+
for (const { id, value } of selections) record[id] = value;
|
|
18716
|
+
return record;
|
|
18717
|
+
}
|
|
18718
|
+
function recordToSelectionArray(value) {
|
|
18719
|
+
if (typeof value !== "object" || value === null) return [];
|
|
18720
|
+
return Object.entries(value).flatMap(([id, entry]) => typeof entry === "string" || typeof entry === "boolean" ? [{
|
|
18721
|
+
id,
|
|
18722
|
+
value: entry
|
|
18723
|
+
}] : []);
|
|
18724
|
+
}
|
|
18725
|
+
/**
|
|
18726
|
+
* Also accept the option array that t3code-derived clients send.
|
|
18727
|
+
*
|
|
18728
|
+
* Forge's own surfaces send `{ reasoningEffort: "high" }`. The vendored mobile
|
|
18729
|
+
* client encodes the same choice as `[{ id: "reasoningEffort", value: "high" }]`,
|
|
18730
|
+
* its canonical shape, and the two contract packages never compare notes. So a
|
|
18731
|
+
* person picking a reasoning effort on the phone produced a `startTurn` payload
|
|
18732
|
+
* the server refused outright with "Expected object, got [...]" — not a dropped
|
|
18733
|
+
* option, a turn that never ran at all.
|
|
18734
|
+
*
|
|
18735
|
+
* Tolerated here rather than changed in the vendored encoder: this accepts both
|
|
18736
|
+
* shapes from any client, while `@t3tools/contracts` keeps the canonical form
|
|
18737
|
+
* it shares with upstream. The array is normalised into the object the provider
|
|
18738
|
+
* adapters already read, so nothing downstream learns a second shape.
|
|
18739
|
+
*
|
|
18740
|
+
* The object member stays first because it is what every Forge surface sends.
|
|
18741
|
+
* `Schema.Struct` rejects an array outright rather than decoding it to an empty
|
|
18742
|
+
* object, so an array falls through to the member built for it.
|
|
18743
|
+
*/
|
|
18744
|
+
const CodexModelOptions = require_Schema$1.Union([CodexModelOptionsObject, require_Schema$1.ArraySchema(ProviderOptionSelection).pipe(require_Schema$1.decodeTo(CodexModelOptionsObject, require_Schema$1.transformOrFail({
|
|
18745
|
+
decode: (selections) => require_Schema$1.succeed(selectionArrayToRecord(selections)),
|
|
18746
|
+
encode: (value) => require_Schema$1.succeed(recordToSelectionArray(value))
|
|
18747
|
+
})))]);
|
|
18748
|
+
const ClaudeModelOptions = require_Schema$1.Union([ClaudeModelOptionsObject, require_Schema$1.ArraySchema(ProviderOptionSelection).pipe(require_Schema$1.decodeTo(ClaudeModelOptionsObject, require_Schema$1.transformOrFail({
|
|
18749
|
+
decode: (selections) => require_Schema$1.succeed(selectionArrayToRecord(selections)),
|
|
18750
|
+
encode: (value) => require_Schema$1.succeed(recordToSelectionArray(value))
|
|
18751
|
+
})))]);
|
|
18687
18752
|
require_Schema$1.Struct({
|
|
18688
18753
|
codex: require_Schema$1.optional(CodexModelOptions),
|
|
18689
18754
|
claudeAgent: require_Schema$1.optional(ClaudeModelOptions),
|
|
@@ -18710,20 +18775,6 @@ const ModelCapabilities = require_Schema$1.Struct({
|
|
|
18710
18775
|
contextWindowOptions: require_Schema$1.ArraySchema(ContextWindowOption),
|
|
18711
18776
|
promptInjectedEffortLevels: require_Schema$1.ArraySchema(TrimmedNonEmptyString)
|
|
18712
18777
|
});
|
|
18713
|
-
/**
|
|
18714
|
-
* Generic option value carried by ACP-based provider adapters (cursor, opencode).
|
|
18715
|
-
* Used to pass per-turn options like reasoning effort or thinking toggles to
|
|
18716
|
-
* the agent without baking them into model-specific schemas.
|
|
18717
|
-
*
|
|
18718
|
-
* Mirrors t3code's @t3tools/contracts ProviderOptionSelection — required by
|
|
18719
|
-
* the ported ACP runtime (apps/server/src/provider/acp/*) so cursor + opencode
|
|
18720
|
-
* adapters can carry user-selected reasoning levels through the session.
|
|
18721
|
-
*/
|
|
18722
|
-
const ProviderOptionSelectionValue = require_Schema$1.Union([TrimmedNonEmptyString, require_Schema$1.Boolean]);
|
|
18723
|
-
const ProviderOptionSelection = require_Schema$1.Struct({
|
|
18724
|
-
id: TrimmedNonEmptyString,
|
|
18725
|
-
value: ProviderOptionSelectionValue
|
|
18726
|
-
});
|
|
18727
18778
|
function effortLabel(value) {
|
|
18728
18779
|
switch (value) {
|
|
18729
18780
|
case "xhigh": return "Extra High";
|
|
@@ -22376,14 +22427,14 @@ var ServerSettingsError = class extends require_Schema$1.TaggedErrorClass()("Ser
|
|
|
22376
22427
|
...DEFAULT_CLIENT_SETTINGS
|
|
22377
22428
|
});
|
|
22378
22429
|
const CodexModelOptionsPatch = require_Schema$1.Struct({
|
|
22379
|
-
reasoningEffort: require_Schema$1.optionalKey(
|
|
22380
|
-
fastMode: require_Schema$1.optionalKey(
|
|
22430
|
+
reasoningEffort: require_Schema$1.optionalKey(CodexModelOptionsObject.fields.reasoningEffort),
|
|
22431
|
+
fastMode: require_Schema$1.optionalKey(CodexModelOptionsObject.fields.fastMode)
|
|
22381
22432
|
});
|
|
22382
22433
|
const ClaudeModelOptionsPatch = require_Schema$1.Struct({
|
|
22383
|
-
thinking: require_Schema$1.optionalKey(
|
|
22384
|
-
effort: require_Schema$1.optionalKey(
|
|
22385
|
-
fastMode: require_Schema$1.optionalKey(
|
|
22386
|
-
contextWindow: require_Schema$1.optionalKey(
|
|
22434
|
+
thinking: require_Schema$1.optionalKey(ClaudeModelOptionsObject.fields.thinking),
|
|
22435
|
+
effort: require_Schema$1.optionalKey(ClaudeModelOptionsObject.fields.effort),
|
|
22436
|
+
fastMode: require_Schema$1.optionalKey(ClaudeModelOptionsObject.fields.fastMode),
|
|
22437
|
+
contextWindow: require_Schema$1.optionalKey(ClaudeModelOptionsObject.fields.contextWindow)
|
|
22387
22438
|
});
|
|
22388
22439
|
const ModelSelectionPatch = require_Schema$1.Union([require_Schema$1.Struct({
|
|
22389
22440
|
provider: require_Schema$1.optionalKey(require_Schema$1.Literal("codex")),
|
|
@@ -65724,7 +65775,7 @@ function normalizeNumberish(value) {
|
|
|
65724
65775
|
}
|
|
65725
65776
|
//#endregion
|
|
65726
65777
|
//#region package.json
|
|
65727
|
-
var version$1 = "0.10.
|
|
65778
|
+
var version$1 = "0.10.13";
|
|
65728
65779
|
//#endregion
|
|
65729
65780
|
//#region src/sentry.ts
|
|
65730
65781
|
const SERVER_APP_NAME = "forge-server";
|
|
@@ -293990,7 +294041,7 @@ function resolveBuildCommitFromEnv(env) {
|
|
|
293990
294041
|
* environment descriptor down instead of reporting an honest "unknown".
|
|
293991
294042
|
*/
|
|
293992
294043
|
function readBakedBuildCommit() {
|
|
293993
|
-
return "
|
|
294044
|
+
return "75c8e9532c9e35e71d4da1d8d45474fa2855ff1d";
|
|
293994
294045
|
}
|
|
293995
294046
|
async function resolveServerBuildCommit(input) {
|
|
293996
294047
|
if (isFullCommitSha(input.baked)) return input.baked;
|
|
@@ -297071,6 +297122,19 @@ function toProjectorDecodeError(eventType) {
|
|
|
297071
297122
|
});
|
|
297072
297123
|
}
|
|
297073
297124
|
//#endregion
|
|
297125
|
+
//#region src/orchestration/turnAccountSelection.ts
|
|
297126
|
+
/** A per-turn account choice remains local to the thread and cannot change its provider. */
|
|
297127
|
+
function turnAccountSelection(current, requested) {
|
|
297128
|
+
if (!requested || requested.provider !== current.provider) return void 0;
|
|
297129
|
+
if (requested.provider !== "codex" && requested.provider !== "claudeAgent") return void 0;
|
|
297130
|
+
const currentAccountId = "providerAccountId" in current ? current.providerAccountId : void 0;
|
|
297131
|
+
if (requested.providerAccountId === void 0 || requested.providerAccountId === currentAccountId) return void 0;
|
|
297132
|
+
return {
|
|
297133
|
+
...current,
|
|
297134
|
+
providerAccountId: requested.providerAccountId
|
|
297135
|
+
};
|
|
297136
|
+
}
|
|
297137
|
+
//#endregion
|
|
297074
297138
|
//#region src/orchestration/commandInvariants.ts
|
|
297075
297139
|
function invariantError(commandType, detail) {
|
|
297076
297140
|
return new OrchestrationCommandInvariantError({
|
|
@@ -297609,7 +297673,9 @@ const decideOrchestrationCommand = require_Schema$1.fn("decideOrchestrationComma
|
|
|
297609
297673
|
createdAt: command.createdAt
|
|
297610
297674
|
}
|
|
297611
297675
|
};
|
|
297612
|
-
|
|
297676
|
+
const shouldUpdateAnchor = targetThread.anchorKind !== nextAnchor.anchorKind || targetThread.anchorCmmdId !== nextAnchor.anchorCmmdId;
|
|
297677
|
+
const accountSelection = turnAccountSelection(targetThread.modelSelection, command.modelSelection);
|
|
297678
|
+
if (!shouldUpdateAnchor && !accountSelection) return [userMessageEvent, turnStartRequestedEvent];
|
|
297613
297679
|
return [
|
|
297614
297680
|
{
|
|
297615
297681
|
...withEventBase({
|
|
@@ -297623,6 +297689,7 @@ const decideOrchestrationCommand = require_Schema$1.fn("decideOrchestrationComma
|
|
|
297623
297689
|
threadId: command.threadId,
|
|
297624
297690
|
anchorKind: nextAnchor.anchorKind,
|
|
297625
297691
|
anchorCmmdId: nextAnchor.anchorCmmdId,
|
|
297692
|
+
...accountSelection ? { modelSelection: accountSelection } : {},
|
|
297626
297693
|
updatedAt: command.createdAt
|
|
297627
297694
|
}
|
|
297628
297695
|
},
|
package/dist/bin.mjs
CHANGED
|
@@ -18601,16 +18601,71 @@ const CLAUDE_CODE_EFFORT_OPTIONS = [
|
|
|
18601
18601
|
const CODEX_DEFAULT_MODEL = "gpt-6-astra";
|
|
18602
18602
|
const CODEX_SPARK_MODEL = "gpt-5.3-codex-spark";
|
|
18603
18603
|
const CLAUDE_DEFAULT_MODEL = "claude-fable-5-1";
|
|
18604
|
-
const
|
|
18604
|
+
const ProviderOptionSelection = Struct({
|
|
18605
|
+
id: TrimmedNonEmptyString,
|
|
18606
|
+
value: Union([TrimmedNonEmptyString, Boolean$1])
|
|
18607
|
+
});
|
|
18608
|
+
/**
|
|
18609
|
+
* The object form on its own, exported so callers that need the individual
|
|
18610
|
+
* field schemas can reach them. The exported `CodexModelOptions` below is a
|
|
18611
|
+
* union and has no `.fields`.
|
|
18612
|
+
*/
|
|
18613
|
+
const CodexModelOptionsObject = Struct({
|
|
18605
18614
|
reasoningEffort: optional$4(Literals(CODEX_REASONING_EFFORT_OPTIONS)),
|
|
18606
18615
|
fastMode: optional$4(Boolean$1)
|
|
18607
18616
|
});
|
|
18608
|
-
|
|
18617
|
+
/** The object form on its own; see {@link CodexModelOptionsObject}. */
|
|
18618
|
+
const ClaudeModelOptionsObject = Struct({
|
|
18609
18619
|
thinking: optional$4(Boolean$1),
|
|
18610
18620
|
effort: optional$4(Literals(CLAUDE_CODE_EFFORT_OPTIONS)),
|
|
18611
18621
|
fastMode: optional$4(Boolean$1),
|
|
18612
18622
|
contextWindow: optional$4(String$1)
|
|
18613
18623
|
});
|
|
18624
|
+
/**
|
|
18625
|
+
* `[{ id, value }]` folded into `{ [id]: value }`.
|
|
18626
|
+
*
|
|
18627
|
+
* Duplicate ids keep the last, which is what an object literal would have done
|
|
18628
|
+
* had the sender used one.
|
|
18629
|
+
*/
|
|
18630
|
+
function selectionArrayToRecord(selections) {
|
|
18631
|
+
const record = {};
|
|
18632
|
+
for (const { id, value } of selections) record[id] = value;
|
|
18633
|
+
return record;
|
|
18634
|
+
}
|
|
18635
|
+
function recordToSelectionArray(value) {
|
|
18636
|
+
if (typeof value !== "object" || value === null) return [];
|
|
18637
|
+
return Object.entries(value).flatMap(([id, entry]) => typeof entry === "string" || typeof entry === "boolean" ? [{
|
|
18638
|
+
id,
|
|
18639
|
+
value: entry
|
|
18640
|
+
}] : []);
|
|
18641
|
+
}
|
|
18642
|
+
/**
|
|
18643
|
+
* Also accept the option array that t3code-derived clients send.
|
|
18644
|
+
*
|
|
18645
|
+
* Forge's own surfaces send `{ reasoningEffort: "high" }`. The vendored mobile
|
|
18646
|
+
* client encodes the same choice as `[{ id: "reasoningEffort", value: "high" }]`,
|
|
18647
|
+
* its canonical shape, and the two contract packages never compare notes. So a
|
|
18648
|
+
* person picking a reasoning effort on the phone produced a `startTurn` payload
|
|
18649
|
+
* the server refused outright with "Expected object, got [...]" — not a dropped
|
|
18650
|
+
* option, a turn that never ran at all.
|
|
18651
|
+
*
|
|
18652
|
+
* Tolerated here rather than changed in the vendored encoder: this accepts both
|
|
18653
|
+
* shapes from any client, while `@t3tools/contracts` keeps the canonical form
|
|
18654
|
+
* it shares with upstream. The array is normalised into the object the provider
|
|
18655
|
+
* adapters already read, so nothing downstream learns a second shape.
|
|
18656
|
+
*
|
|
18657
|
+
* The object member stays first because it is what every Forge surface sends.
|
|
18658
|
+
* `Schema.Struct` rejects an array outright rather than decoding it to an empty
|
|
18659
|
+
* object, so an array falls through to the member built for it.
|
|
18660
|
+
*/
|
|
18661
|
+
const CodexModelOptions = Union([CodexModelOptionsObject, ArraySchema(ProviderOptionSelection).pipe(decodeTo(CodexModelOptionsObject, transformOrFail({
|
|
18662
|
+
decode: (selections) => succeed(selectionArrayToRecord(selections)),
|
|
18663
|
+
encode: (value) => succeed(recordToSelectionArray(value))
|
|
18664
|
+
})))]);
|
|
18665
|
+
const ClaudeModelOptions = Union([ClaudeModelOptionsObject, ArraySchema(ProviderOptionSelection).pipe(decodeTo(ClaudeModelOptionsObject, transformOrFail({
|
|
18666
|
+
decode: (selections) => succeed(selectionArrayToRecord(selections)),
|
|
18667
|
+
encode: (value) => succeed(recordToSelectionArray(value))
|
|
18668
|
+
})))]);
|
|
18614
18669
|
Struct({
|
|
18615
18670
|
codex: optional$4(CodexModelOptions),
|
|
18616
18671
|
claudeAgent: optional$4(ClaudeModelOptions),
|
|
@@ -18637,10 +18692,6 @@ const ModelCapabilities = Struct({
|
|
|
18637
18692
|
contextWindowOptions: ArraySchema(ContextWindowOption),
|
|
18638
18693
|
promptInjectedEffortLevels: ArraySchema(TrimmedNonEmptyString)
|
|
18639
18694
|
});
|
|
18640
|
-
const ProviderOptionSelection = Struct({
|
|
18641
|
-
id: TrimmedNonEmptyString,
|
|
18642
|
-
value: Union([TrimmedNonEmptyString, Boolean$1])
|
|
18643
|
-
});
|
|
18644
18695
|
function effortLabel(value) {
|
|
18645
18696
|
switch (value) {
|
|
18646
18697
|
case "xhigh": return "Extra High";
|
|
@@ -22201,14 +22252,14 @@ var ServerSettingsError = class extends TaggedErrorClass()("ServerSettingsError"
|
|
|
22201
22252
|
...DEFAULT_CLIENT_SETTINGS
|
|
22202
22253
|
});
|
|
22203
22254
|
const CodexModelOptionsPatch = Struct({
|
|
22204
|
-
reasoningEffort: optionalKey(
|
|
22205
|
-
fastMode: optionalKey(
|
|
22255
|
+
reasoningEffort: optionalKey(CodexModelOptionsObject.fields.reasoningEffort),
|
|
22256
|
+
fastMode: optionalKey(CodexModelOptionsObject.fields.fastMode)
|
|
22206
22257
|
});
|
|
22207
22258
|
const ClaudeModelOptionsPatch = Struct({
|
|
22208
|
-
thinking: optionalKey(
|
|
22209
|
-
effort: optionalKey(
|
|
22210
|
-
fastMode: optionalKey(
|
|
22211
|
-
contextWindow: optionalKey(
|
|
22259
|
+
thinking: optionalKey(ClaudeModelOptionsObject.fields.thinking),
|
|
22260
|
+
effort: optionalKey(ClaudeModelOptionsObject.fields.effort),
|
|
22261
|
+
fastMode: optionalKey(ClaudeModelOptionsObject.fields.fastMode),
|
|
22262
|
+
contextWindow: optionalKey(ClaudeModelOptionsObject.fields.contextWindow)
|
|
22212
22263
|
});
|
|
22213
22264
|
const ModelSelectionPatch = Union([Struct({
|
|
22214
22265
|
provider: optionalKey(Literal("codex")),
|
|
@@ -65444,7 +65495,7 @@ function normalizeNumberish(value) {
|
|
|
65444
65495
|
}
|
|
65445
65496
|
//#endregion
|
|
65446
65497
|
//#region package.json
|
|
65447
|
-
var version$1 = "0.10.
|
|
65498
|
+
var version$1 = "0.10.13";
|
|
65448
65499
|
//#endregion
|
|
65449
65500
|
//#region src/sentry.ts
|
|
65450
65501
|
const SERVER_APP_NAME = "forge-server";
|
|
@@ -293442,7 +293493,7 @@ function resolveBuildCommitFromEnv(env) {
|
|
|
293442
293493
|
* environment descriptor down instead of reporting an honest "unknown".
|
|
293443
293494
|
*/
|
|
293444
293495
|
function readBakedBuildCommit() {
|
|
293445
|
-
return "
|
|
293496
|
+
return "75c8e9532c9e35e71d4da1d8d45474fa2855ff1d";
|
|
293446
293497
|
}
|
|
293447
293498
|
async function resolveServerBuildCommit(input) {
|
|
293448
293499
|
if (isFullCommitSha(input.baked)) return input.baked;
|
|
@@ -296503,6 +296554,19 @@ function toProjectorDecodeError(eventType) {
|
|
|
296503
296554
|
});
|
|
296504
296555
|
}
|
|
296505
296556
|
//#endregion
|
|
296557
|
+
//#region src/orchestration/turnAccountSelection.ts
|
|
296558
|
+
/** A per-turn account choice remains local to the thread and cannot change its provider. */
|
|
296559
|
+
function turnAccountSelection(current, requested) {
|
|
296560
|
+
if (!requested || requested.provider !== current.provider) return void 0;
|
|
296561
|
+
if (requested.provider !== "codex" && requested.provider !== "claudeAgent") return void 0;
|
|
296562
|
+
const currentAccountId = "providerAccountId" in current ? current.providerAccountId : void 0;
|
|
296563
|
+
if (requested.providerAccountId === void 0 || requested.providerAccountId === currentAccountId) return void 0;
|
|
296564
|
+
return {
|
|
296565
|
+
...current,
|
|
296566
|
+
providerAccountId: requested.providerAccountId
|
|
296567
|
+
};
|
|
296568
|
+
}
|
|
296569
|
+
//#endregion
|
|
296506
296570
|
//#region src/orchestration/commandInvariants.ts
|
|
296507
296571
|
function invariantError(commandType, detail) {
|
|
296508
296572
|
return new OrchestrationCommandInvariantError({
|
|
@@ -297041,7 +297105,9 @@ const decideOrchestrationCommand = fn$1("decideOrchestrationCommand")(function*
|
|
|
297041
297105
|
createdAt: command.createdAt
|
|
297042
297106
|
}
|
|
297043
297107
|
};
|
|
297044
|
-
|
|
297108
|
+
const shouldUpdateAnchor = targetThread.anchorKind !== nextAnchor.anchorKind || targetThread.anchorCmmdId !== nextAnchor.anchorCmmdId;
|
|
297109
|
+
const accountSelection = turnAccountSelection(targetThread.modelSelection, command.modelSelection);
|
|
297110
|
+
if (!shouldUpdateAnchor && !accountSelection) return [userMessageEvent, turnStartRequestedEvent];
|
|
297045
297111
|
return [
|
|
297046
297112
|
{
|
|
297047
297113
|
...withEventBase({
|
|
@@ -297055,6 +297121,7 @@ const decideOrchestrationCommand = fn$1("decideOrchestrationCommand")(function*
|
|
|
297055
297121
|
threadId: command.threadId,
|
|
297056
297122
|
anchorKind: nextAnchor.anchorKind,
|
|
297057
297123
|
anchorCmmdId: nextAnchor.anchorCmmdId,
|
|
297124
|
+
...accountSelection ? { modelSelection: accountSelection } : {},
|
|
297058
297125
|
updatedAt: command.createdAt
|
|
297059
297126
|
}
|
|
297060
297127
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jspdf.es.min-Hx4pHu4X.js","assets/rolldown-runtime-hePW80VL.js","assets/preload-helper-Czpn1I53.js","assets/typeof-B5XbjTb1.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Va as n,za as r}from"./Stream-C4tOsbfQ.js";import{Ht as i,Vt as a,i as o,o as s,r as c}from"./useTriggerFocusGuards-DPZ1smix.js";import{Nn as l,g as u}from"./CompositeItem-Dm91tFrl.js";import{t as d}from"./preload-helper-Czpn1I53.js";import{C as f,S as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j,v as M,x as N,y as P}from"./canvasStateStore-CqQQvGP5.js";import{t as F}from"./toggle-dld7kzOP.js";var I=l(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),ee=l(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),L=l(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),R=l(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),z=l(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),B=l(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),te=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),ne=l(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),re=l(`mouse-pointer`,[[`path`,{d:`M12.586 12.586 19 19`,key:`ea5xo7`}],[`path`,{d:`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`,key:`277e5u`}]]),ie=l(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),ae=l(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),oe=l(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),se=l(`wand`,[[`path`,{d:`M15 4V2`,key:`z1p9b7`}],[`path`,{d:`M15 16v-2`,key:`px0unx`}],[`path`,{d:`M8 9h2`,key:`1g203m`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M17.8 11.8 19 13`,key:`yihg8r`}],[`path`,{d:`M15 9h.01`,key:`x1ddxp`}],[`path`,{d:`M17.8 6.2 19 5`,key:`fd4us0`}],[`path`,{d:`m3 21 9-9`,key:`1jfql5`}],[`path`,{d:`M12.2 6.2 11 5`,key:`i3da3b`}]]),ce=l(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),le=l(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),V=e(n(),1),ue=[{id:`instagram-post`,label:`Instagram Post`,category:`Social Media`,width:1080,height:1080},{id:`instagram-story`,label:`Instagram Story`,category:`Social Media`,width:1080,height:1920},{id:`facebook-cover`,label:`Facebook Cover`,category:`Social Media`,width:820,height:312},{id:`linkedin-banner`,label:`LinkedIn Banner`,category:`Social Media`,width:1584,height:396},{id:`twitter-post`,label:`Twitter/X Post`,category:`Social Media`,width:1200,height:675},{id:`youtube-thumbnail`,label:`YouTube Thumbnail`,category:`Social Media`,width:1280,height:720},{id:`presentation`,label:`Presentation 16:9`,category:`Presentation`,width:1920,height:1080},{id:`a4`,label:`A4`,category:`Print`,width:2480,height:3508},{id:`us-letter`,label:`US Letter`,category:`Print`,width:2550,height:3300},{id:`business-card`,label:`Business Card`,category:`Print`,width:1050,height:600},{id:`invoice`,label:`Invoice`,category:`Documents`,width:2480,height:3508}],de=new Map(ue.map(e=>[e.id,e]));[...new Set(ue.map(e=>e.category))];function fe(){let e=new Map;for(let t of ue){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return e}function pe(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function me(e,t){let n=URL.createObjectURL(e);pe(n,t),URL.revokeObjectURL(n)}function he(e,t,n,r,i=40){let a=n-i*2,o=r-i*2,s=Math.min(a/e,o/t,1),c=e*s,l=t*s;return{scale:s,offsetX:(n-c)/2,offsetY:(r-l)/2}}function ge(e){return Math.min(e*1.25,5)}function _e(e){return Math.max(e/1.25,.1)}function ve(e,t){return{rect:`Rectangle`,circle:`Circle`,line:`Line`,polygon:`Polygon`,textbox:`Text`,"i-text":`Text`,image:`Image`,path:`Drawing`,group:`Group`}[e]??`Object ${t+1}`}var ye=Object.defineProperty,be=(e,t)=>{let n={};for(var r in e)ye(n,r,{get:e[r],enumerable:!0});return t||ye(n,Symbol.toStringTag,{value:`Module`}),n};function xe(e){return xe=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},xe(e)}function Se(e){var t=function(e,t){if(xe(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(xe(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return xe(t)==`symbol`?t:t+``}function H(e,t,n){return(t=Se(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ce=class{constructor(){H(this,`browserShadowBlurConstant`,1),H(this,`DPI`,96),H(this,`devicePixelRatio`,typeof window<`u`?window.devicePixelRatio:1),H(this,`perfLimitSizeTotal`,2097152),H(this,`maxCacheSideLimit`,4096),H(this,`minCacheSideLimit`,256),H(this,`disableStyleCopyPaste`,!1),H(this,`enableGLFiltering`,!0),H(this,`textureSize`,4096),H(this,`forceGLPutImageData`,!1),H(this,`cachesBoundsOfCurve`,!1),H(this,`fontPaths`,{}),H(this,`NUM_FRACTION_DIGITS`,4)}},U=new class extends Ce{constructor(e){super(),this.configure(e)}configure(e={}){Object.assign(this,e)}addFonts(e={}){this.fontPaths={...this.fontPaths,...e}}removeFonts(e=[]){e.forEach(e=>{delete this.fontPaths[e]})}clearFonts(){this.fontPaths={}}restoreDefaults(e){let t=new Ce,n=e?.reduce((e,n)=>(e[n]=t[n],e),{})||t;this.configure(n)}},we=(e,...t)=>console[e](`fabric`,...t),Te=class extends Error{constructor(e,t){super(`fabric: ${e}`,t)}},Ee=class extends Te{constructor(e){super(`${e} 'options.signal' is in 'aborted' state`)}},De=class{},Oe=class extends De{testPrecision(e,t){let n=`precision ${t} float;\nvoid main(){}`,r=e.createShader(e.FRAGMENT_SHADER);return!!r&&(e.shaderSource(r,n),e.compileShader(r),!!e.getShaderParameter(r,e.COMPILE_STATUS))}queryWebGL(e){let t=e.getContext(`webgl`);t&&(this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.GLPrecision=[`highp`,`mediump`,`lowp`].find(e=>this.testPrecision(t,e)),t.getExtension(`WEBGL_lose_context`).loseContext(),we(`log`,`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(e){return!!this.maxTextureSize&&this.maxTextureSize>=e}},ke={},Ae,je=()=>Ae||={document,window,isTouchSupported:`ontouchstart`in window||`ontouchstart`in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Oe,dispose(){},copyPasteData:ke},Me=()=>je().document,Ne=()=>je().window,Pe=()=>Math.max(U.devicePixelRatio??Ne().devicePixelRatio,1),Fe=new class{constructor(){H(this,`boundsOfCurveCache`,{}),this.charWidthsCache=new Map}getFontCache({fontFamily:e,fontStyle:t,fontWeight:n}){e=e.toLowerCase();let r=this.charWidthsCache;r.has(e)||r.set(e,new Map);let i=r.get(e),a=`${t.toLowerCase()}_${(n+``).toLowerCase()}`;return i.has(a)||i.set(a,new Map),i.get(a)}clearFontCache(e){e?this.charWidthsCache.delete((e||``).toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(e){let{perfLimitSizeTotal:t}=U,n=Math.sqrt(t*e);return[Math.floor(n),Math.floor(t/n)]}},Ie=`7.4.0`;function Le(){}var Re=Math.PI/2,ze=Math.PI/4,Be=2*Math.PI,Ve=Math.PI/180,He=Object.freeze([1,0,0,1,0,0]),W=`center`,G=`left`,Ue=`bottom`,We=`right`,Ge=`none`,Ke=/\r?\n/,qe=`moving`,Je=`scaling`,Ye=`rotating`,Xe=`rotate`,Ze=`skewing`,Qe=`resizing`,$e=`modifyPoly`,et=`changed`,tt=`scale`,nt=`scaleX`,rt=`scaleY`,it=`skewX`,at=`skewY`,ot=`fill`,st=`stroke`,ct=`modified`,lt=`normal`,ut=`json`,K=new class{constructor(){this[ut]=new Map,this.svg=new Map}has(e){return this[ut].has(e)}getClass(e){let t=this[ut].get(e);if(!t)throw new Te(`No class registered for ${e}`);return t}setClass(e,t){t?this[ut].set(t,e):(this[ut].set(e.type,e),this[ut].set(e.type.toLowerCase(),e))}getSVGClass(e){return this.svg.get(e)}setSVGClass(e,t){this.svg.set(t??e.type.toLowerCase(),e)}},dt=new class extends Array{remove(e){let t=this.indexOf(e);t>-1&&this.splice(t,1)}cancelAll(){let e=this.splice(0);return e.forEach(e=>e.abort()),e}cancelByCanvas(e){if(!e)return[];let t=this.filter(t=>t.target===e||typeof t.target==`object`&&t.target?.canvas===e);return t.forEach(e=>e.abort()),t}cancelByTarget(e){if(!e)return[];let t=this.filter(t=>t.target===e);return t.forEach(e=>e.abort()),t}},ft=class{constructor(){H(this,`__eventListeners`,{})}on(e,t){if(this.__eventListeners||={},typeof e==`object`)return Object.entries(e).forEach(([e,t])=>{this.on(e,t)}),()=>this.off(e);if(t){let n=e;return this.__eventListeners[n]||(this.__eventListeners[n]=[]),this.__eventListeners[n].push(t),()=>this.off(n,t)}return()=>!1}once(e,t){if(typeof e==`object`){let t=[];return Object.entries(e).forEach(([e,n])=>{t.push(this.once(e,n))}),()=>t.forEach(e=>e())}if(t){let n=this.on(e,function(...e){t.call(this,...e),n()});return n}return()=>!1}_removeEventListener(e,t){if(this.__eventListeners[e])if(t){let n=this.__eventListeners[e],r=n.indexOf(t);r>-1&&n.splice(r,1)}else this.__eventListeners[e]=[]}off(e,t){if(this.__eventListeners)if(e===void 0)for(let e in this.__eventListeners)this._removeEventListener(e);else typeof e==`object`?Object.entries(e).forEach(([e,t])=>{this._removeEventListener(e,t)}):this._removeEventListener(e,t)}fire(e,t){if(!this.__eventListeners)return;let n=this.__eventListeners[e]?.concat();if(n)for(let e=0;e<n.length;e++)n[e].call(this,t||{})}},pt=(e,t)=>{let n=e.indexOf(t);return n!==-1&&e.splice(n,1),e},mt=e=>{if(e===0)return 1;switch(Math.abs(e)/Re){case 1:case 3:return 0;case 2:return-1}return Math.cos(e)},ht=e=>{if(e===0)return 0;let t=e/Re,n=Math.sign(e);switch(t){case 1:return n;case 2:return 0;case 3:return-n}return Math.sin(e)},q=class e{constructor(e=0,t=0){typeof e==`object`?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(t){return new e(this.x+t.x,this.y+t.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(t){return new e(this.x+t,this.y+t)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(t){return new e(this.x-t.x,this.y-t.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(t){return new e(this.x-t,this.y-t)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(t){return new e(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new e(this.x*t,this.y*t)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(t){return new e(this.x/t.x,this.y/t.y)}scalarDivide(t){return new e(this.x/t,this.y/t)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(t,n=.5){return n=Math.max(Math.min(1,n),0),new e(this.x+(t.x-this.x)*n,this.y+(t.y-this.y)*n)}distanceFrom(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}midPointFrom(e){return this.lerp(e)}min(t){return new e(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new e(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return`${this.x},${this.y}`}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){let t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}clone(){return new e(this.x,this.y)}rotate(t,n=gt){let r=ht(t),i=mt(t),a=this.subtract(n);return new e(a.x*i-a.y*r,a.x*r+a.y*i).add(n)}transform(t,n=!1){return new e(t[0]*this.x+t[2]*this.y+(n?0:t[4]),t[1]*this.x+t[3]*this.y+(n?0:t[5]))}},gt=new q(0,0),_t=e=>!!e&&Array.isArray(e._objects);function vt(e){class t extends e{constructor(...e){super(...e),H(this,`_objects`,[])}_onObjectAdded(e){}_onObjectRemoved(e){}_onStackOrderChanged(e){}add(...e){let t=this._objects.push(...e);return e.forEach(e=>this._onObjectAdded(e)),t}insertAt(e,...t){return this._objects.splice(e,0,...t),t.forEach(e=>this._onObjectAdded(e)),this._objects.length}remove(...e){let t=this._objects,n=[];return e.forEach(e=>{let r=t.indexOf(e);r!==-1&&(t.splice(r,1),n.push(e),this._onObjectRemoved(e))}),n}forEachObject(e){this.getObjects().forEach((t,n,r)=>e(t,n,r))}getObjects(...e){return e.length===0?[...this._objects]:this._objects.filter(t=>t.isType(...e))}item(e){return this._objects[e]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(e,n){return!!this._objects.includes(e)||!!n&&this._objects.some(n=>n instanceof t&&n.contains(e,!0))}complexity(){return this._objects.reduce((e,t)=>e+=t.complexity?t.complexity():0,0)}sendObjectToBack(e){return!(!e||e===this._objects[0])&&(pt(this._objects,e),this._objects.unshift(e),this._onStackOrderChanged(e),!0)}bringObjectToFront(e){return!(!e||e===this._objects[this._objects.length-1])&&(pt(this._objects,e),this._objects.push(e),this._onStackOrderChanged(e),!0)}sendObjectBackwards(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==0){let r=this.findNewLowerIndex(e,n,t);return pt(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}bringObjectForward(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==this._objects.length-1){let r=this.findNewUpperIndex(e,n,t);return pt(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}moveObjectTo(e,t){return e!==this._objects[t]&&(pt(this._objects,e),this._objects.splice(t,0,e),this._onStackOrderChanged(e),!0)}findNewLowerIndex(e,t,n){let r;if(n){r=t;for(let n=t-1;n>=0;--n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t-1;return r}findNewUpperIndex(e,t,n){let r;if(n){r=t;for(let n=t+1;n<this._objects.length;++n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t+1;return r}collectObjects({left:e,top:t,width:n,height:r},{includeIntersecting:i=!0}={}){let a=[],o=new q(e,t),s=o.add(new q(n,r));for(let e=this._objects.length-1;e>=0;e--){let t=this._objects[e];t.selectable&&t.visible&&(i&&t.intersectsWithRect(o,s)||t.isContainedWithinRect(o,s)||i&&t.containsPoint(o)||i&&t.containsPoint(s))&&a.push(t)}return a}}return t}var yt=class extends ft{_setOptions(e={}){for(let t in e)this.set(t,e[t])}_setObject(e){for(let t in e)this._set(t,e[t])}set(e,t){return typeof e==`object`?this._setObject(e):this._set(e,t),this}_set(e,t){this[e]=t}toggle(e){let t=this.get(e);return typeof t==`boolean`&&this.set(e,!t),this}get(e){return this[e]}};function bt(e){return Ne().requestAnimationFrame(e)}function xt(e){return Ne().cancelAnimationFrame(e)}var St=0,Ct=()=>St++,wt=()=>{let e=Me().createElement(`canvas`);if(!e||e.getContext===void 0)throw new Te("Failed to create `canvas` element");return e},Tt=()=>Me().createElement(`img`),Et=e=>{var t;let n=Dt(e);return(t=n.getContext(`2d`))==null||t.drawImage(e,0,0),n},Dt=e=>{let t=wt();return t.width=e.width,t.height=e.height,t},Ot=(e,t,n)=>e.toDataURL(`image/${t}`,n),kt=(e,t,n)=>new Promise((r,i)=>{e.toBlob(r,`image/${t}`,n)}),J=e=>e*Ve,At=e=>e/Ve,jt=e=>e.every((e,t)=>e===He[t]),Mt=(e,t,n)=>new q(e).transform(t,n),Nt=e=>{let t=1/(e[0]*e[3]-e[1]*e[2]),n=[t*e[3],-t*e[1],-t*e[2],t*e[0],0,0],{x:r,y:i}=new q(e[4],e[5]).transform(n,!0);return n[4]=-r,n[5]=-i,n},Y=(e,t,n)=>[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],n?0:e[0]*t[4]+e[2]*t[5]+e[4],n?0:e[1]*t[4]+e[3]*t[5]+e[5]],Pt=(e,t)=>e.reduceRight((e,n)=>n&&e?Y(n,e,t):n||e,void 0)||He.concat(),Ft=([e,t])=>Math.atan2(t,e),It=([e,t])=>Math.sqrt(e*e+t*t),Lt=([,,e,t])=>Math.sqrt(e*e+t*t),Rt=e=>{let t=Ft(e),n=e[0]**2+e[1]**2,r=Math.sqrt(n),i=(e[0]*e[3]-e[2]*e[1])/r,a=Math.atan2(e[0]*e[2]+e[1]*e[3],n);return{angle:At(t),scaleX:r,scaleY:i,skewX:At(a),skewY:0,translateX:e[4]||0,translateY:e[5]||0}},zt=(e,t=0)=>[1,0,0,1,e,t];function Bt({angle:e=0}={},{x:t=0,y:n=0}={}){let r=J(e),i=mt(r),a=ht(r);return[i,a,-a,i,t?t-(i*t-a*n):0,n?n-(a*t+i*n):0]}var Vt=(e,t=e)=>[e,0,0,t,0,0],Ht=e=>Math.tan(J(e)),Ut=e=>[1,0,Ht(e),1,0,0],Wt=e=>[1,Ht(e),0,1,0,0],Gt=({scaleX:e=1,scaleY:t=1,flipX:n=!1,flipY:r=!1,skewX:i=0,skewY:a=0})=>{let o=Vt(n?-e:e,r?-t:t);return i&&(o=Y(o,Ut(i),!0)),a&&(o=Y(o,Wt(a),!0)),o},Kt=e=>{let{translateX:t=0,translateY:n=0,angle:r=0}=e,i=zt(t,n);r&&(i=Y(i,Bt({angle:r})));let a=Gt(e);return jt(a)||(i=Y(i,a)),i},qt=(e,{signal:t,crossOrigin:n=null}={})=>new Promise(function(r,i){if(t&&t.aborted)return i(new Ee(`loadImage`));let a=Tt(),o;t&&(o=function(e){a.src=``,i(e)},t.addEventListener(`abort`,o,{once:!0}));let s=function(){a.onload=a.onerror=null,o&&t?.removeEventListener(`abort`,o),r(a)};e?(a.onload=s,a.onerror=function(){o&&t?.removeEventListener(`abort`,o),i(new Te(`Error loading ${a.src}`))},n&&(a.crossOrigin=n),a.src=e):s()}),Jt=(e,{signal:t,reviver:n=Le}={})=>new Promise((r,i)=>{let a=[];t&&t.addEventListener(`abort`,i,{once:!0}),Promise.allSettled(e.map(e=>K.getClass(e.type).fromObject(e,{signal:t}))).then(async t=>{for(let[r,i]of t.entries())if(i.status===`fulfilled`&&(await n(e[r],i.value),a.push(i.value)),i.status===`rejected`){let t=await n(e[r],void 0,i.reason);t&&a.push(t)}r(a)}).catch(e=>{a.forEach(e=>{e.dispose&&e.dispose()}),i(e)}).finally(()=>{t&&t.removeEventListener(`abort`,i)})}),Yt=(e,{signal:t}={})=>new Promise((n,r)=>{let i=[];t&&t.addEventListener(`abort`,r,{once:!0});let a=Object.values(e).map(e=>e&&e.type&&K.has(e.type)?Jt([e],{signal:t}).then(([e])=>(i.push(e),e)):e),o=Object.keys(e);Promise.all(a).then(e=>e.reduce((e,t,n)=>(e[o[n]]=t,e),{})).then(n).catch(e=>{i.forEach(e=>{e.dispose&&e.dispose()}),r(e)}).finally(()=>{t&&t.removeEventListener(`abort`,r)})}),Xt=(e,t=[])=>t.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{}),Zt=(e,t)=>Object.keys(e).reduce((n,r)=>(t(e[r],r,e)&&(n[r]=e[r]),n),{}),X=(e,t)=>parseFloat(Number(e).toFixed(t)),Qt=e=>`matrix(`+e.map(e=>X(e,U.NUM_FRACTION_DIGITS)).join(` `)+`)`,$t=e=>!!e&&e.toLive!==void 0,en=e=>!!e&&typeof e.toObject==`function`,tn=e=>!!e&&e.offsetX!==void 0&&`source`in e,nn=e=>!!e&&`multiSelectionStacking`in e;function rn(e){let t=e&&an(e),n=0,r=0;if(!e||!t)return{left:n,top:r};let i=e,a=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(n=o.scrollLeft||a.scrollLeft||0,r=o.scrollTop||a.scrollTop||0):(n+=i.scrollLeft||0,r+=i.scrollTop||0),i.nodeType!==1||i.style.position!==`fixed`););return{left:n,top:r}}var an=e=>e.ownerDocument||null,on=e=>e.ownerDocument?.defaultView||null,sn=(e,t,{width:n,height:r},i=1)=>{e.width=n,e.height=r,i>1&&(e.setAttribute(`width`,(n*i).toString()),e.setAttribute(`height`,(r*i).toString()),t.scale(i,i))},cn=(e,{width:t,height:n})=>{t&&(e.style.width=typeof t==`number`?`${t}px`:t),n&&(e.style.height=typeof n==`number`?`${n}px`:n)};function ln(e){return e.onselectstart!==void 0&&(e.onselectstart=()=>!1),e.style.userSelect=Ge,e}var un=class{constructor(e){H(this,`_originalCanvasStyle`,void 0),H(this,`lower`,void 0);let t=this.createLowerCanvas(e);this.lower={el:t,ctx:t.getContext(`2d`)}}createLowerCanvas(e){let t=(n=e)&&n.getContext!==void 0?e:e&&Me().getElementById(e)||wt();var n;if(t.hasAttribute(`data-fabric`))throw new Te(`Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?`);return this._originalCanvasStyle=t.style.cssText,t.setAttribute(`data-fabric`,`main`),t.classList.add(`lower-canvas`),t}cleanupDOM({width:e,height:t}){let{el:n}=this.lower;n.classList.remove(`lower-canvas`),n.removeAttribute(`data-fabric`),n.setAttribute(`width`,`${e}`),n.setAttribute(`height`,`${t}`),n.style.cssText=this._originalCanvasStyle||``,this._originalCanvasStyle=void 0}setDimensions(e,t){let{el:n,ctx:r}=this.lower;sn(n,r,e,t)}setCSSDimensions(e){cn(this.lower.el,e)}calcOffset(){return function(e){let t=e&&an(e),n={left:0,top:0};if(!t)return n;let r=on(e)?.getComputedStyle(e,null)||{};n.left+=parseInt(r.borderLeftWidth,10)||0,n.top+=parseInt(r.borderTopWidth,10)||0,n.left+=parseInt(r.paddingLeft,10)||0,n.top+=parseInt(r.paddingTop,10)||0;let i={left:0,top:0},a=t.documentElement;e.getBoundingClientRect!==void 0&&(i=e.getBoundingClientRect());let o=rn(e);return{left:i.left+o.left-(a.clientLeft||0)+n.left,top:i.top+o.top-(a.clientTop||0)+n.top}}(this.lower.el)}dispose(){je().dispose(this.lower.el),delete this.lower}},dn={backgroundVpt:!0,backgroundColor:``,overlayVpt:!0,overlayColor:``,includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...He],patternQuality:`best`},fn=be({capitalize:()=>pn,escapeXml:()=>Z,graphemeSplit:()=>hn}),pn=(e,t=!1)=>`${e.charAt(0).toUpperCase()}${t?e.slice(1):e.slice(1).toLowerCase()}`,Z=e=>e.toString().replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`),mn,hn=e=>{if(mn||mn||(mn=`Intl`in Ne()&&`Segmenter`in Intl&&new Intl.Segmenter(void 0,{granularity:`grapheme`})),mn){let t=mn.segment(e);return Array.from(t).map(({segment:e})=>e)}return gn(e)},gn=e=>{let t=[];for(let n,r=0;r<e.length;r++)!1!==(n=_n(e,r))&&t.push(n);return t},_n=(e,t)=>{let n=e.charCodeAt(t);if(isNaN(n))return``;if(n<55296||n>57343)return e.charAt(t);if(55296<=n&&n<=56319){if(e.length<=t+1)throw`High surrogate without following low surrogate`;let n=e.charCodeAt(t+1);if(56320>n||n>57343)throw`High surrogate without following low surrogate`;return e.charAt(t)+e.charAt(t+1)}if(t===0)throw`Low surrogate without preceding high surrogate`;let r=e.charCodeAt(t-1);if(55296>r||r>56319)throw`Low surrogate without preceding high surrogate`;return!1},vn=class e extends vt(yt){get lowerCanvasEl(){return this.elements.lower?.el}get contextContainer(){return this.elements.lower?.ctx}static getDefaults(){return e.ownDefaults}constructor(e,t={}){super(),Object.assign(this,this.constructor.getDefaults()),this.set(t),this.initElements(e),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(e){this.elements=new un(e)}add(...e){let t=super.add(...e);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(e,...t){let n=super.insertAt(e,...t);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(...e){let t=super.remove(...e);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(e){e.canvas&&e.canvas!==this&&(we(`warn`,`Canvas is trying to add an object that belongs to a different canvas.
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Ba as t,Va as n,za as r}from"./Stream-C4tOsbfQ.js";import{Ht as i,Vt as a,i as o,o as s,r as c}from"./useTriggerFocusGuards-O7DUCec0.js";import{Nn as l,g as u}from"./CompositeItem-D6h2WFmU.js";import{t as d}from"./preload-helper-Czpn1I53.js";import{C as f,S as p,_ as m,a as h,b as g,c as _,d as v,f as y,g as b,h as x,i as S,l as C,m as w,n as T,o as E,p as D,r as O,s as k,t as A,u as j,v as M,x as N,y as P}from"./canvasStateStore-DUZyBLSv.js";import{t as F}from"./toggle-CWmPePti.js";var I=l(`file-code`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]),ee=l(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),L=l(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),R=l(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),z=l(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),B=l(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),te=l(`maximize`,[[`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`,key:`1dcmit`}],[`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`,key:`1e4gt3`}],[`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`,key:`wsl5sc`}],[`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`,key:`18trek`}]]),ne=l(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),re=l(`mouse-pointer`,[[`path`,{d:`M12.586 12.586 19 19`,key:`ea5xo7`}],[`path`,{d:`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`,key:`277e5u`}]]),ie=l(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),ae=l(`redo-2`,[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]),oe=l(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),se=l(`wand`,[[`path`,{d:`M15 4V2`,key:`z1p9b7`}],[`path`,{d:`M15 16v-2`,key:`px0unx`}],[`path`,{d:`M8 9h2`,key:`1g203m`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M17.8 11.8 19 13`,key:`yihg8r`}],[`path`,{d:`M15 9h.01`,key:`x1ddxp`}],[`path`,{d:`M17.8 6.2 19 5`,key:`fd4us0`}],[`path`,{d:`m3 21 9-9`,key:`1jfql5`}],[`path`,{d:`M12.2 6.2 11 5`,key:`i3da3b`}]]),ce=l(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),le=l(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),V=e(n(),1),ue=[{id:`instagram-post`,label:`Instagram Post`,category:`Social Media`,width:1080,height:1080},{id:`instagram-story`,label:`Instagram Story`,category:`Social Media`,width:1080,height:1920},{id:`facebook-cover`,label:`Facebook Cover`,category:`Social Media`,width:820,height:312},{id:`linkedin-banner`,label:`LinkedIn Banner`,category:`Social Media`,width:1584,height:396},{id:`twitter-post`,label:`Twitter/X Post`,category:`Social Media`,width:1200,height:675},{id:`youtube-thumbnail`,label:`YouTube Thumbnail`,category:`Social Media`,width:1280,height:720},{id:`presentation`,label:`Presentation 16:9`,category:`Presentation`,width:1920,height:1080},{id:`a4`,label:`A4`,category:`Print`,width:2480,height:3508},{id:`us-letter`,label:`US Letter`,category:`Print`,width:2550,height:3300},{id:`business-card`,label:`Business Card`,category:`Print`,width:1050,height:600},{id:`invoice`,label:`Invoice`,category:`Documents`,width:2480,height:3508}],de=new Map(ue.map(e=>[e.id,e]));[...new Set(ue.map(e=>e.category))];function fe(){let e=new Map;for(let t of ue){let n=e.get(t.category)??[];n.push(t),e.set(t.category,n)}return e}function pe(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function me(e,t){let n=URL.createObjectURL(e);pe(n,t),URL.revokeObjectURL(n)}function he(e,t,n,r,i=40){let a=n-i*2,o=r-i*2,s=Math.min(a/e,o/t,1),c=e*s,l=t*s;return{scale:s,offsetX:(n-c)/2,offsetY:(r-l)/2}}function ge(e){return Math.min(e*1.25,5)}function _e(e){return Math.max(e/1.25,.1)}function ve(e,t){return{rect:`Rectangle`,circle:`Circle`,line:`Line`,polygon:`Polygon`,textbox:`Text`,"i-text":`Text`,image:`Image`,path:`Drawing`,group:`Group`}[e]??`Object ${t+1}`}var ye=Object.defineProperty,be=(e,t)=>{let n={};for(var r in e)ye(n,r,{get:e[r],enumerable:!0});return t||ye(n,Symbol.toStringTag,{value:`Module`}),n};function xe(e){return xe=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},xe(e)}function Se(e){var t=function(e,t){if(xe(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(xe(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}(e,`string`);return xe(t)==`symbol`?t:t+``}function H(e,t,n){return(t=Se(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ce=class{constructor(){H(this,`browserShadowBlurConstant`,1),H(this,`DPI`,96),H(this,`devicePixelRatio`,typeof window<`u`?window.devicePixelRatio:1),H(this,`perfLimitSizeTotal`,2097152),H(this,`maxCacheSideLimit`,4096),H(this,`minCacheSideLimit`,256),H(this,`disableStyleCopyPaste`,!1),H(this,`enableGLFiltering`,!0),H(this,`textureSize`,4096),H(this,`forceGLPutImageData`,!1),H(this,`cachesBoundsOfCurve`,!1),H(this,`fontPaths`,{}),H(this,`NUM_FRACTION_DIGITS`,4)}},U=new class extends Ce{constructor(e){super(),this.configure(e)}configure(e={}){Object.assign(this,e)}addFonts(e={}){this.fontPaths={...this.fontPaths,...e}}removeFonts(e=[]){e.forEach(e=>{delete this.fontPaths[e]})}clearFonts(){this.fontPaths={}}restoreDefaults(e){let t=new Ce,n=e?.reduce((e,n)=>(e[n]=t[n],e),{})||t;this.configure(n)}},we=(e,...t)=>console[e](`fabric`,...t),Te=class extends Error{constructor(e,t){super(`fabric: ${e}`,t)}},Ee=class extends Te{constructor(e){super(`${e} 'options.signal' is in 'aborted' state`)}},De=class{},Oe=class extends De{testPrecision(e,t){let n=`precision ${t} float;\nvoid main(){}`,r=e.createShader(e.FRAGMENT_SHADER);return!!r&&(e.shaderSource(r,n),e.compileShader(r),!!e.getShaderParameter(r,e.COMPILE_STATUS))}queryWebGL(e){let t=e.getContext(`webgl`);t&&(this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.GLPrecision=[`highp`,`mediump`,`lowp`].find(e=>this.testPrecision(t,e)),t.getExtension(`WEBGL_lose_context`).loseContext(),we(`log`,`WebGL: max texture size ${this.maxTextureSize}`))}isSupported(e){return!!this.maxTextureSize&&this.maxTextureSize>=e}},ke={},Ae,je=()=>Ae||={document,window,isTouchSupported:`ontouchstart`in window||`ontouchstart`in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Oe,dispose(){},copyPasteData:ke},Me=()=>je().document,Ne=()=>je().window,Pe=()=>Math.max(U.devicePixelRatio??Ne().devicePixelRatio,1),Fe=new class{constructor(){H(this,`boundsOfCurveCache`,{}),this.charWidthsCache=new Map}getFontCache({fontFamily:e,fontStyle:t,fontWeight:n}){e=e.toLowerCase();let r=this.charWidthsCache;r.has(e)||r.set(e,new Map);let i=r.get(e),a=`${t.toLowerCase()}_${(n+``).toLowerCase()}`;return i.has(a)||i.set(a,new Map),i.get(a)}clearFontCache(e){e?this.charWidthsCache.delete((e||``).toLowerCase()):this.charWidthsCache=new Map}limitDimsByArea(e){let{perfLimitSizeTotal:t}=U,n=Math.sqrt(t*e);return[Math.floor(n),Math.floor(t/n)]}},Ie=`7.4.0`;function Le(){}var Re=Math.PI/2,ze=Math.PI/4,Be=2*Math.PI,Ve=Math.PI/180,He=Object.freeze([1,0,0,1,0,0]),W=`center`,G=`left`,Ue=`bottom`,We=`right`,Ge=`none`,Ke=/\r?\n/,qe=`moving`,Je=`scaling`,Ye=`rotating`,Xe=`rotate`,Ze=`skewing`,Qe=`resizing`,$e=`modifyPoly`,et=`changed`,tt=`scale`,nt=`scaleX`,rt=`scaleY`,it=`skewX`,at=`skewY`,ot=`fill`,st=`stroke`,ct=`modified`,lt=`normal`,ut=`json`,K=new class{constructor(){this[ut]=new Map,this.svg=new Map}has(e){return this[ut].has(e)}getClass(e){let t=this[ut].get(e);if(!t)throw new Te(`No class registered for ${e}`);return t}setClass(e,t){t?this[ut].set(t,e):(this[ut].set(e.type,e),this[ut].set(e.type.toLowerCase(),e))}getSVGClass(e){return this.svg.get(e)}setSVGClass(e,t){this.svg.set(t??e.type.toLowerCase(),e)}},dt=new class extends Array{remove(e){let t=this.indexOf(e);t>-1&&this.splice(t,1)}cancelAll(){let e=this.splice(0);return e.forEach(e=>e.abort()),e}cancelByCanvas(e){if(!e)return[];let t=this.filter(t=>t.target===e||typeof t.target==`object`&&t.target?.canvas===e);return t.forEach(e=>e.abort()),t}cancelByTarget(e){if(!e)return[];let t=this.filter(t=>t.target===e);return t.forEach(e=>e.abort()),t}},ft=class{constructor(){H(this,`__eventListeners`,{})}on(e,t){if(this.__eventListeners||={},typeof e==`object`)return Object.entries(e).forEach(([e,t])=>{this.on(e,t)}),()=>this.off(e);if(t){let n=e;return this.__eventListeners[n]||(this.__eventListeners[n]=[]),this.__eventListeners[n].push(t),()=>this.off(n,t)}return()=>!1}once(e,t){if(typeof e==`object`){let t=[];return Object.entries(e).forEach(([e,n])=>{t.push(this.once(e,n))}),()=>t.forEach(e=>e())}if(t){let n=this.on(e,function(...e){t.call(this,...e),n()});return n}return()=>!1}_removeEventListener(e,t){if(this.__eventListeners[e])if(t){let n=this.__eventListeners[e],r=n.indexOf(t);r>-1&&n.splice(r,1)}else this.__eventListeners[e]=[]}off(e,t){if(this.__eventListeners)if(e===void 0)for(let e in this.__eventListeners)this._removeEventListener(e);else typeof e==`object`?Object.entries(e).forEach(([e,t])=>{this._removeEventListener(e,t)}):this._removeEventListener(e,t)}fire(e,t){if(!this.__eventListeners)return;let n=this.__eventListeners[e]?.concat();if(n)for(let e=0;e<n.length;e++)n[e].call(this,t||{})}},pt=(e,t)=>{let n=e.indexOf(t);return n!==-1&&e.splice(n,1),e},mt=e=>{if(e===0)return 1;switch(Math.abs(e)/Re){case 1:case 3:return 0;case 2:return-1}return Math.cos(e)},ht=e=>{if(e===0)return 0;let t=e/Re,n=Math.sign(e);switch(t){case 1:return n;case 2:return 0;case 3:return-n}return Math.sin(e)},q=class e{constructor(e=0,t=0){typeof e==`object`?(this.x=e.x,this.y=e.y):(this.x=e,this.y=t)}add(t){return new e(this.x+t.x,this.y+t.y)}addEquals(e){return this.x+=e.x,this.y+=e.y,this}scalarAdd(t){return new e(this.x+t,this.y+t)}scalarAddEquals(e){return this.x+=e,this.y+=e,this}subtract(t){return new e(this.x-t.x,this.y-t.y)}subtractEquals(e){return this.x-=e.x,this.y-=e.y,this}scalarSubtract(t){return new e(this.x-t,this.y-t)}scalarSubtractEquals(e){return this.x-=e,this.y-=e,this}multiply(t){return new e(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new e(this.x*t,this.y*t)}scalarMultiplyEquals(e){return this.x*=e,this.y*=e,this}divide(t){return new e(this.x/t.x,this.y/t.y)}scalarDivide(t){return new e(this.x/t,this.y/t)}scalarDivideEquals(e){return this.x/=e,this.y/=e,this}eq(e){return this.x===e.x&&this.y===e.y}lt(e){return this.x<e.x&&this.y<e.y}lte(e){return this.x<=e.x&&this.y<=e.y}gt(e){return this.x>e.x&&this.y>e.y}gte(e){return this.x>=e.x&&this.y>=e.y}lerp(t,n=.5){return n=Math.max(Math.min(1,n),0),new e(this.x+(t.x-this.x)*n,this.y+(t.y-this.y)*n)}distanceFrom(e){let t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}midPointFrom(e){return this.lerp(e)}min(t){return new e(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new e(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return`${this.x},${this.y}`}setXY(e,t){return this.x=e,this.y=t,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setFromPoint(e){return this.x=e.x,this.y=e.y,this}swap(e){let t=this.x,n=this.y;this.x=e.x,this.y=e.y,e.x=t,e.y=n}clone(){return new e(this.x,this.y)}rotate(t,n=gt){let r=ht(t),i=mt(t),a=this.subtract(n);return new e(a.x*i-a.y*r,a.x*r+a.y*i).add(n)}transform(t,n=!1){return new e(t[0]*this.x+t[2]*this.y+(n?0:t[4]),t[1]*this.x+t[3]*this.y+(n?0:t[5]))}},gt=new q(0,0),_t=e=>!!e&&Array.isArray(e._objects);function vt(e){class t extends e{constructor(...e){super(...e),H(this,`_objects`,[])}_onObjectAdded(e){}_onObjectRemoved(e){}_onStackOrderChanged(e){}add(...e){let t=this._objects.push(...e);return e.forEach(e=>this._onObjectAdded(e)),t}insertAt(e,...t){return this._objects.splice(e,0,...t),t.forEach(e=>this._onObjectAdded(e)),this._objects.length}remove(...e){let t=this._objects,n=[];return e.forEach(e=>{let r=t.indexOf(e);r!==-1&&(t.splice(r,1),n.push(e),this._onObjectRemoved(e))}),n}forEachObject(e){this.getObjects().forEach((t,n,r)=>e(t,n,r))}getObjects(...e){return e.length===0?[...this._objects]:this._objects.filter(t=>t.isType(...e))}item(e){return this._objects[e]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(e,n){return!!this._objects.includes(e)||!!n&&this._objects.some(n=>n instanceof t&&n.contains(e,!0))}complexity(){return this._objects.reduce((e,t)=>e+=t.complexity?t.complexity():0,0)}sendObjectToBack(e){return!(!e||e===this._objects[0])&&(pt(this._objects,e),this._objects.unshift(e),this._onStackOrderChanged(e),!0)}bringObjectToFront(e){return!(!e||e===this._objects[this._objects.length-1])&&(pt(this._objects,e),this._objects.push(e),this._onStackOrderChanged(e),!0)}sendObjectBackwards(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==0){let r=this.findNewLowerIndex(e,n,t);return pt(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}bringObjectForward(e,t){if(!e)return!1;let n=this._objects.indexOf(e);if(n!==this._objects.length-1){let r=this.findNewUpperIndex(e,n,t);return pt(this._objects,e),this._objects.splice(r,0,e),this._onStackOrderChanged(e),!0}return!1}moveObjectTo(e,t){return e!==this._objects[t]&&(pt(this._objects,e),this._objects.splice(t,0,e),this._onStackOrderChanged(e),!0)}findNewLowerIndex(e,t,n){let r;if(n){r=t;for(let n=t-1;n>=0;--n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t-1;return r}findNewUpperIndex(e,t,n){let r;if(n){r=t;for(let n=t+1;n<this._objects.length;++n)if(e.isOverlapping(this._objects[n])){r=n;break}}else r=t+1;return r}collectObjects({left:e,top:t,width:n,height:r},{includeIntersecting:i=!0}={}){let a=[],o=new q(e,t),s=o.add(new q(n,r));for(let e=this._objects.length-1;e>=0;e--){let t=this._objects[e];t.selectable&&t.visible&&(i&&t.intersectsWithRect(o,s)||t.isContainedWithinRect(o,s)||i&&t.containsPoint(o)||i&&t.containsPoint(s))&&a.push(t)}return a}}return t}var yt=class extends ft{_setOptions(e={}){for(let t in e)this.set(t,e[t])}_setObject(e){for(let t in e)this._set(t,e[t])}set(e,t){return typeof e==`object`?this._setObject(e):this._set(e,t),this}_set(e,t){this[e]=t}toggle(e){let t=this.get(e);return typeof t==`boolean`&&this.set(e,!t),this}get(e){return this[e]}};function bt(e){return Ne().requestAnimationFrame(e)}function xt(e){return Ne().cancelAnimationFrame(e)}var St=0,Ct=()=>St++,wt=()=>{let e=Me().createElement(`canvas`);if(!e||e.getContext===void 0)throw new Te("Failed to create `canvas` element");return e},Tt=()=>Me().createElement(`img`),Et=e=>{var t;let n=Dt(e);return(t=n.getContext(`2d`))==null||t.drawImage(e,0,0),n},Dt=e=>{let t=wt();return t.width=e.width,t.height=e.height,t},Ot=(e,t,n)=>e.toDataURL(`image/${t}`,n),kt=(e,t,n)=>new Promise((r,i)=>{e.toBlob(r,`image/${t}`,n)}),J=e=>e*Ve,At=e=>e/Ve,jt=e=>e.every((e,t)=>e===He[t]),Mt=(e,t,n)=>new q(e).transform(t,n),Nt=e=>{let t=1/(e[0]*e[3]-e[1]*e[2]),n=[t*e[3],-t*e[1],-t*e[2],t*e[0],0,0],{x:r,y:i}=new q(e[4],e[5]).transform(n,!0);return n[4]=-r,n[5]=-i,n},Y=(e,t,n)=>[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],n?0:e[0]*t[4]+e[2]*t[5]+e[4],n?0:e[1]*t[4]+e[3]*t[5]+e[5]],Pt=(e,t)=>e.reduceRight((e,n)=>n&&e?Y(n,e,t):n||e,void 0)||He.concat(),Ft=([e,t])=>Math.atan2(t,e),It=([e,t])=>Math.sqrt(e*e+t*t),Lt=([,,e,t])=>Math.sqrt(e*e+t*t),Rt=e=>{let t=Ft(e),n=e[0]**2+e[1]**2,r=Math.sqrt(n),i=(e[0]*e[3]-e[2]*e[1])/r,a=Math.atan2(e[0]*e[2]+e[1]*e[3],n);return{angle:At(t),scaleX:r,scaleY:i,skewX:At(a),skewY:0,translateX:e[4]||0,translateY:e[5]||0}},zt=(e,t=0)=>[1,0,0,1,e,t];function Bt({angle:e=0}={},{x:t=0,y:n=0}={}){let r=J(e),i=mt(r),a=ht(r);return[i,a,-a,i,t?t-(i*t-a*n):0,n?n-(a*t+i*n):0]}var Vt=(e,t=e)=>[e,0,0,t,0,0],Ht=e=>Math.tan(J(e)),Ut=e=>[1,0,Ht(e),1,0,0],Wt=e=>[1,Ht(e),0,1,0,0],Gt=({scaleX:e=1,scaleY:t=1,flipX:n=!1,flipY:r=!1,skewX:i=0,skewY:a=0})=>{let o=Vt(n?-e:e,r?-t:t);return i&&(o=Y(o,Ut(i),!0)),a&&(o=Y(o,Wt(a),!0)),o},Kt=e=>{let{translateX:t=0,translateY:n=0,angle:r=0}=e,i=zt(t,n);r&&(i=Y(i,Bt({angle:r})));let a=Gt(e);return jt(a)||(i=Y(i,a)),i},qt=(e,{signal:t,crossOrigin:n=null}={})=>new Promise(function(r,i){if(t&&t.aborted)return i(new Ee(`loadImage`));let a=Tt(),o;t&&(o=function(e){a.src=``,i(e)},t.addEventListener(`abort`,o,{once:!0}));let s=function(){a.onload=a.onerror=null,o&&t?.removeEventListener(`abort`,o),r(a)};e?(a.onload=s,a.onerror=function(){o&&t?.removeEventListener(`abort`,o),i(new Te(`Error loading ${a.src}`))},n&&(a.crossOrigin=n),a.src=e):s()}),Jt=(e,{signal:t,reviver:n=Le}={})=>new Promise((r,i)=>{let a=[];t&&t.addEventListener(`abort`,i,{once:!0}),Promise.allSettled(e.map(e=>K.getClass(e.type).fromObject(e,{signal:t}))).then(async t=>{for(let[r,i]of t.entries())if(i.status===`fulfilled`&&(await n(e[r],i.value),a.push(i.value)),i.status===`rejected`){let t=await n(e[r],void 0,i.reason);t&&a.push(t)}r(a)}).catch(e=>{a.forEach(e=>{e.dispose&&e.dispose()}),i(e)}).finally(()=>{t&&t.removeEventListener(`abort`,i)})}),Yt=(e,{signal:t}={})=>new Promise((n,r)=>{let i=[];t&&t.addEventListener(`abort`,r,{once:!0});let a=Object.values(e).map(e=>e&&e.type&&K.has(e.type)?Jt([e],{signal:t}).then(([e])=>(i.push(e),e)):e),o=Object.keys(e);Promise.all(a).then(e=>e.reduce((e,t,n)=>(e[o[n]]=t,e),{})).then(n).catch(e=>{i.forEach(e=>{e.dispose&&e.dispose()}),r(e)}).finally(()=>{t&&t.removeEventListener(`abort`,r)})}),Xt=(e,t=[])=>t.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{}),Zt=(e,t)=>Object.keys(e).reduce((n,r)=>(t(e[r],r,e)&&(n[r]=e[r]),n),{}),X=(e,t)=>parseFloat(Number(e).toFixed(t)),Qt=e=>`matrix(`+e.map(e=>X(e,U.NUM_FRACTION_DIGITS)).join(` `)+`)`,$t=e=>!!e&&e.toLive!==void 0,en=e=>!!e&&typeof e.toObject==`function`,tn=e=>!!e&&e.offsetX!==void 0&&`source`in e,nn=e=>!!e&&`multiSelectionStacking`in e;function rn(e){let t=e&&an(e),n=0,r=0;if(!e||!t)return{left:n,top:r};let i=e,a=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;i&&(i.parentNode||i.host)&&(i=i.parentNode||i.host,i===t?(n=o.scrollLeft||a.scrollLeft||0,r=o.scrollTop||a.scrollTop||0):(n+=i.scrollLeft||0,r+=i.scrollTop||0),i.nodeType!==1||i.style.position!==`fixed`););return{left:n,top:r}}var an=e=>e.ownerDocument||null,on=e=>e.ownerDocument?.defaultView||null,sn=(e,t,{width:n,height:r},i=1)=>{e.width=n,e.height=r,i>1&&(e.setAttribute(`width`,(n*i).toString()),e.setAttribute(`height`,(r*i).toString()),t.scale(i,i))},cn=(e,{width:t,height:n})=>{t&&(e.style.width=typeof t==`number`?`${t}px`:t),n&&(e.style.height=typeof n==`number`?`${n}px`:n)};function ln(e){return e.onselectstart!==void 0&&(e.onselectstart=()=>!1),e.style.userSelect=Ge,e}var un=class{constructor(e){H(this,`_originalCanvasStyle`,void 0),H(this,`lower`,void 0);let t=this.createLowerCanvas(e);this.lower={el:t,ctx:t.getContext(`2d`)}}createLowerCanvas(e){let t=(n=e)&&n.getContext!==void 0?e:e&&Me().getElementById(e)||wt();var n;if(t.hasAttribute(`data-fabric`))throw new Te(`Trying to initialize a canvas that has already been initialized. Did you forget to dispose the canvas?`);return this._originalCanvasStyle=t.style.cssText,t.setAttribute(`data-fabric`,`main`),t.classList.add(`lower-canvas`),t}cleanupDOM({width:e,height:t}){let{el:n}=this.lower;n.classList.remove(`lower-canvas`),n.removeAttribute(`data-fabric`),n.setAttribute(`width`,`${e}`),n.setAttribute(`height`,`${t}`),n.style.cssText=this._originalCanvasStyle||``,this._originalCanvasStyle=void 0}setDimensions(e,t){let{el:n,ctx:r}=this.lower;sn(n,r,e,t)}setCSSDimensions(e){cn(this.lower.el,e)}calcOffset(){return function(e){let t=e&&an(e),n={left:0,top:0};if(!t)return n;let r=on(e)?.getComputedStyle(e,null)||{};n.left+=parseInt(r.borderLeftWidth,10)||0,n.top+=parseInt(r.borderTopWidth,10)||0,n.left+=parseInt(r.paddingLeft,10)||0,n.top+=parseInt(r.paddingTop,10)||0;let i={left:0,top:0},a=t.documentElement;e.getBoundingClientRect!==void 0&&(i=e.getBoundingClientRect());let o=rn(e);return{left:i.left+o.left-(a.clientLeft||0)+n.left,top:i.top+o.top-(a.clientTop||0)+n.top}}(this.lower.el)}dispose(){je().dispose(this.lower.el),delete this.lower}},dn={backgroundVpt:!0,backgroundColor:``,overlayVpt:!0,overlayColor:``,includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...He],patternQuality:`best`},fn=be({capitalize:()=>pn,escapeXml:()=>Z,graphemeSplit:()=>hn}),pn=(e,t=!1)=>`${e.charAt(0).toUpperCase()}${t?e.slice(1):e.slice(1).toLowerCase()}`,Z=e=>e.toString().replace(/&/g,`&`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/</g,`<`).replace(/>/g,`>`),mn,hn=e=>{if(mn||mn||(mn=`Intl`in Ne()&&`Segmenter`in Intl&&new Intl.Segmenter(void 0,{granularity:`grapheme`})),mn){let t=mn.segment(e);return Array.from(t).map(({segment:e})=>e)}return gn(e)},gn=e=>{let t=[];for(let n,r=0;r<e.length;r++)!1!==(n=_n(e,r))&&t.push(n);return t},_n=(e,t)=>{let n=e.charCodeAt(t);if(isNaN(n))return``;if(n<55296||n>57343)return e.charAt(t);if(55296<=n&&n<=56319){if(e.length<=t+1)throw`High surrogate without following low surrogate`;let n=e.charCodeAt(t+1);if(56320>n||n>57343)throw`High surrogate without following low surrogate`;return e.charAt(t)+e.charAt(t+1)}if(t===0)throw`Low surrogate without preceding high surrogate`;let r=e.charCodeAt(t-1);if(55296>r||r>56319)throw`Low surrogate without preceding high surrogate`;return!1},vn=class e extends vt(yt){get lowerCanvasEl(){return this.elements.lower?.el}get contextContainer(){return this.elements.lower?.ctx}static getDefaults(){return e.ownDefaults}constructor(e,t={}){super(),Object.assign(this,this.constructor.getDefaults()),this.set(t),this.initElements(e),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(e){this.elements=new un(e)}add(...e){let t=super.add(...e);return e.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}insertAt(e,...t){let n=super.insertAt(e,...t);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),n}remove(...e){let t=super.remove(...e);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(e){e.canvas&&e.canvas!==this&&(we(`warn`,`Canvas is trying to add an object that belongs to a different canvas.
|
|
3
3
|
Resulting to default behavior: removing object from previous canvas and adding to new canvas`),e.canvas.remove(e)),e._set(`canvas`,this),e.setCoords(),this.fire(`object:added`,{target:e}),e.fire(`added`,{target:this})}_onObjectRemoved(e){e._set(`canvas`,void 0),this.fire(`object:removed`,{target:e}),e.fire(`removed`,{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?Pe():1}calcOffset(){return this._offset=this.elements.calcOffset()}getWidth(){return this.width}getHeight(){return this.height}_setDimensionsImpl(e,{cssOnly:t=!1,backstoreOnly:n=!1}={}){if(!t){let t={width:this.width,height:this.height,...e};this.elements.setDimensions(t,this.getRetinaScaling()),this.hasLostContext=!0,this.width=t.width,this.height=t.height}n||this.elements.setCSSDimensions(e),this.calcOffset()}setDimensions(e,t){this._setDimensionsImpl(e,t),t&&t.cssOnly||this.requestRenderAll()}getZoom(){return It(this.viewportTransform)}setViewportTransform(e){this.viewportTransform=e,this.calcViewportBoundaries(),this.renderOnAddRemove&&this.requestRenderAll()}zoomToPoint(e,t){let n=e,r=[...this.viewportTransform],i=Mt(e,Nt(r));r[0]=t,r[3]=t;let a=Mt(i,r);r[4]+=n.x-a.x,r[5]+=n.y-a.y,this.setViewportTransform(r)}setZoom(e){this.zoomToPoint(new q(0,0),e)}absolutePan(e){let t=[...this.viewportTransform];return t[4]=-e.x,t[5]=-e.y,this.setViewportTransform(t)}relativePan(e){return this.absolutePan(new q(-e.x-this.viewportTransform[4],-e.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(e){e.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor=``,this.overlayColor=``,this.clearContext(this.getContext()),this.fire(`canvas:cleared`),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=bt(()=>this.renderAndReset()))}calcViewportBoundaries(){let e=this.width,t=this.height,n=Nt(this.viewportTransform),r=Mt({x:0,y:0},n),i=Mt({x:e,y:t},n),a=r.min(i),o=r.max(i);return this.vptCoords={tl:a,tr:new q(o.x,a.y),bl:new q(a.x,o.y),br:o}}cancelRequestedRender(){this.nextRenderHandle&&=(xt(this.nextRenderHandle),0)}drawControls(e){}renderCanvas(e,t){if(this.destroyed)return;let n=this.viewportTransform,r=this.clipPath;this.calcViewportBoundaries(),this.clearContext(e),e.imageSmoothingEnabled=this.imageSmoothingEnabled,e.patternQuality=this.patternQuality,this.fire(`before:render`,{ctx:e}),this._renderBackground(e),e.save(),e.transform(n[0],n[1],n[2],n[3],n[4],n[5]),this._renderObjects(e,t),e.restore(),this.controlsAboveOverlay||this.skipControlsDrawing||this.drawControls(e),r&&(r._set(`canvas`,this),r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(e,r)),this._renderOverlay(e),this.controlsAboveOverlay&&!this.skipControlsDrawing&&this.drawControls(e),this.fire(`after:render`,{ctx:e}),this.__cleanupTask&&=(this.__cleanupTask(),void 0)}drawClipPathOnCanvas(e,t){let n=this.viewportTransform;e.save(),e.transform(...n),e.globalCompositeOperation=`destination-in`,t.transform(e),e.scale(1/t.zoomX,1/t.zoomY),e.drawImage(t._cacheCanvas,-t.cacheTranslationX,-t.cacheTranslationY),e.restore()}_renderObjects(e,t){for(let n=0,r=t.length;n<r;++n)t[n]&&t[n].render(e)}_renderBackgroundOrOverlay(e,t){let n=this[`${t}Color`],r=this[`${t}Image`],i=this.viewportTransform,a=this[`${t}Vpt`];if(!n&&!r)return;let o=$t(n);if(n){if(e.save(),e.beginPath(),e.moveTo(0,0),e.lineTo(this.width,0),e.lineTo(this.width,this.height),e.lineTo(0,this.height),e.closePath(),e.fillStyle=o?n.toLive(e):n,a&&e.transform(...i),o){e.transform(1,0,0,1,n.offsetX||0,n.offsetY||0);let t=n.gradientTransform||n.patternTransform;t&&e.transform(...t)}e.fill(),e.restore()}if(r){e.save();let{skipOffscreen:t}=this;this.skipOffscreen=a,a&&e.transform(...i),r.render(e),this.skipOffscreen=t,e.restore()}}_renderBackground(e){this._renderBackgroundOrOverlay(e,`background`)}_renderOverlay(e){this._renderBackgroundOrOverlay(e,`overlay`)}getCenterPoint(){return new q(this.width/2,this.height/2)}centerObjectH(e){return this._centerObject(e,new q(this.getCenterPoint().x,e.getCenterPoint().y))}centerObjectV(e){return this._centerObject(e,new q(e.getCenterPoint().x,this.getCenterPoint().y))}centerObject(e){return this._centerObject(e,this.getCenterPoint())}viewportCenterObject(e){return this._centerObject(e,this.getVpCenter())}viewportCenterObjectH(e){return this._centerObject(e,new q(this.getVpCenter().x,e.getCenterPoint().y))}viewportCenterObjectV(e){return this._centerObject(e,new q(e.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return Mt(this.getCenterPoint(),Nt(this.viewportTransform))}_centerObject(e,t){e.setXY(t,W,W),e.setCoords(),this.renderOnAddRemove&&this.requestRenderAll()}toDatalessJSON(e){return this.toDatalessObject(e)}toObject(e){return this._toObjectMethod(`toObject`,e)}toJSON(){return this.toObject()}toDatalessObject(e){return this._toObjectMethod(`toDatalessObject`,e)}_toObjectMethod(e,t){let n=this.clipPath,r=n&&!n.excludeFromExport?this._toObject(n,e,t):null;return{version:Ie,...Xt(this,t),objects:this._objects.filter(e=>!e.excludeFromExport).map(n=>this._toObject(n,e,t)),...this.__serializeBgOverlay(e,t),...r?{clipPath:r}:null}}_toObject(e,t,n){let r;this.includeDefaultValues||(r=e.includeDefaultValues,e.includeDefaultValues=!1);let i=e[t](n);return this.includeDefaultValues||(e.includeDefaultValues=!!r),i}__serializeBgOverlay(e,t){let n={},r=this.backgroundImage,i=this.overlayImage,a=this.backgroundColor,o=this.overlayColor;return $t(a)?a.excludeFromExport||(n.background=a.toObject(t)):a&&(n.background=a),$t(o)?o.excludeFromExport||(n.overlay=o.toObject(t)):o&&(n.overlay=o),r&&!r.excludeFromExport&&(n.backgroundImage=this._toObject(r,e,t)),i&&!i.excludeFromExport&&(n.overlayImage=this._toObject(i,e,t)),n}toSVG(e={},t){e.reviver=t;let n=[];return this._setSVGPreamble(n,e),this._setSVGHeader(n,e),this.clipPath&&n.push(`<g clip-path="url(#${Z(this.clipPath.clipPathId??``)})" >\n`),this._setSVGBgOverlayColor(n,`background`),this._setSVGBgOverlayImage(n,`backgroundImage`,t),this._setSVGObjects(n,t),this.clipPath&&n.push(`</g>
|
|
4
4
|
`),this._setSVGBgOverlayColor(n,`overlay`),this._setSVGBgOverlayImage(n,`overlayImage`,t),n.push(`</svg>`),n.join(``)}_setSVGPreamble(e,t){t.suppressPreamble||e.push(`<?xml version="1.0" encoding="`,t.encoding||`UTF-8`,`" standalone="no" ?>
|
|
5
5
|
`,`<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" `,`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
@@ -438,4 +438,4 @@ void main() {
|
|
|
438
438
|
gl_FragColor = color;
|
|
439
439
|
}
|
|
440
440
|
`}applyTo2d({imageData:{data:e}}){let t=-this.vibrance;for(let n=0;n<e.length;n+=4){let r=e[n],i=e[n+1],a=e[n+2],o=Math.max(r,i,a),s=(r+i+a)/3,c=2*Math.abs(o-s)/255*t;e[n]+=o===r?0:(o-r)*c,e[n+1]+=o===i?0:(o-i)*c,e[n+2]+=o===a?0:(o-a)*c}}sendUniformData(e,t){e.uniform1f(t.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};H(il,`type`,`Vibrance`),H(il,`defaults`,{vibrance:0}),H(il,`uniformLocations`,[`uVibrance`]),K.setClass(il),be({BaseFilter:()=>Q,BlackWhite:()=>Vc,BlendColor:()=>Dc,BlendImage:()=>kc,Blur:()=>Ac,Brightness:()=>jc,Brownie:()=>Fc,ColorMatrix:()=>Nc,Composed:()=>Hc,Contrast:()=>Uc,Convolute:()=>Gc,Gamma:()=>qc,Grayscale:()=>Yc,HueRotation:()=>Zc,Invert:()=>Qc,Kodachrome:()=>Lc,Noise:()=>$c,Pixelate:()=>el,Polaroid:()=>zc,RemoveColor:()=>tl,Resize:()=>nl,Saturation:()=>rl,Sepia:()=>Bc,Technicolor:()=>Rc,Vibrance:()=>il,Vintage:()=>Ic});function al(e){let t=e instanceof uc||e instanceof lc;return{id:e.customId??e.toString(),type:e.type??`object`,left:Math.round(e.left??0),top:Math.round(e.top??0),width:Math.round((e.width??0)*(e.scaleX??1)),height:Math.round((e.height??0)*(e.scaleY??1)),angle:Math.round(e.angle??0),opacity:e.opacity??1,fill:typeof e.fill==`string`?e.fill:null,stroke:typeof e.stroke==`string`?e.stroke:null,strokeWidth:e.strokeWidth??0,...t?{fontFamily:e.fontFamily,fontSize:e.fontSize,fontWeight:e.fontWeight,textAlign:e.textAlign}:{}}}function ol(e){return e.getObjects().filter(e=>e.customId!==`__artboard__`).map((e,t)=>({id:e.customId??`obj-${t}`,type:e.type??`object`,name:e.customName??ve(e.type??`object`,t),visible:e.visible!==!1,locked:!e.selectable}))}function sl(e){let t={left:e.left,top:e.top,selectable:e.selectable!==!1};switch(e.fill!==void 0&&(t.fill=e.fill),e.stroke!==void 0&&(t.stroke=e.stroke),e.strokeWidth!==void 0&&(t.strokeWidth=e.strokeWidth),e.opacity!==void 0&&(t.opacity=e.opacity),e.angle!==void 0&&(t.angle=e.angle),e.scaleX!==void 0&&(t.scaleX=e.scaleX),e.scaleY!==void 0&&(t.scaleY=e.scaleY),e.type){case`rect`:{let n={...t};return e.width!==void 0&&(n.width=e.width),e.height!==void 0&&(n.height=e.height),e.rx!==void 0&&(n.rx=e.rx),e.ry!==void 0&&(n.ry=e.ry),new $a(n)}case`ellipse`:return new Bs({...t,rx:e.rx??(e.width?e.width/2:50),ry:e.ry??(e.height?e.height/2:50)});case`textbox`:{let n={...t};return e.width!==void 0&&(n.width=e.width),e.fontSize!==void 0&&(n.fontSize=e.fontSize),e.fontFamily!==void 0&&(n.fontFamily=e.fontFamily),e.fontWeight!==void 0&&(n.fontWeight=e.fontWeight),e.textAlign!==void 0&&(n.textAlign=e.textAlign),new uc(e.text??``,n)}case`line`:return new Ls([e.left,e.top,e.left+(e.width??100),e.top+(e.height??0)],t);case`path`:return new $a({...t,width:e.width??50,height:e.height??50});default:return new $a({...t,width:e.width??50,height:e.height??50})}}var cl=0;function ll(e){let t=e;return t.customId||=`obj-${++cl}`,t.customId}function ul(e,t){switch(e){case`rect`:return new $a({left:t.x,top:t.y,width:0,height:0,fill:`#6366f1`,stroke:`#4f46e5`,strokeWidth:1});case`circle`:return new Bs({left:t.x,top:t.y,rx:0,ry:0,fill:`#6366f1`,stroke:`#4f46e5`,strokeWidth:1});case`line`:return new Ls([t.x,t.y,t.x,t.y],{stroke:`#000000`,strokeWidth:2});case`polygon`:return new $a({left:t.x,top:t.y,width:0,height:0,fill:`#6366f1`,stroke:`#4f46e5`,strokeWidth:1,rx:8,ry:8});default:return null}}function dl(e){let{activeTool:t,object:n,start:r,pointer:i}=e;return t===`line`&&n instanceof Ls?(n.set({x2:i.x,y2:i.y}),!0):t===`circle`&&n instanceof Bs?(n.set({rx:Math.abs(i.x-r.x)/2,ry:Math.abs(i.y-r.y)/2,left:Math.min(r.x,i.x),top:Math.min(r.y,i.y)}),!0):(n.set({left:Math.min(r.x,i.x),top:Math.min(r.y,i.y),width:Math.abs(i.x-r.x),height:Math.abs(i.y-r.y)}),!0)}function fl(e){return e===`draw`?{isDrawingMode:!0,selection:!0,defaultCursor:`default`,hoverCursor:`move`,pencilBrush:{color:`#000000`,width:3}}:e===`select`?{isDrawingMode:!1,selection:!0,defaultCursor:`default`,hoverCursor:`move`,pencilBrush:null}:{isDrawingMode:!1,selection:!1,defaultCursor:`crosshair`,hoverCursor:`crosshair`,pencilBrush:null}}var $=t(),pl=(0,V.forwardRef)(function({artboardWidth:e,artboardHeight:t,activeTool:n,onSelectionChange:r,onCanvasModified:i,onLayersChange:a,onZoomChange:o},s){let c=(0,V.useRef)(null),l=(0,V.useRef)(null),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useCallback)(()=>{let e=l.current;e&&a(ol(e))},[a]),p=(0,V.useCallback)(()=>{let e=l.current;if(!e)return;let t=e.getActiveObject();if(!t){r([],null);return}r([ll(t)],al(t))},[r]),m=(0,V.useCallback)(()=>{p(),i(),f()},[p,i,f]),h=(0,V.useCallback)(()=>{let n=l.current,r=u.current;if(!n||!r)return;let{width:i,height:a}=r.getBoundingClientRect(),{scale:s,offsetX:c,offsetY:d}=he(e,t,i,a);n.setDimensions({width:i,height:a});let f=n.viewportTransform;f[0]=s,f[3]=s,f[4]=c,f[5]=d,n.setViewportTransform(f),o(s),n.requestRenderAll()},[e,t,o]);return(0,V.useEffect)(()=>{let n=c.current;if(!n)return;let i=new hs(n,{backgroundColor:`transparent`,preserveObjectStacking:!0,selection:!0});l.current=i;let a=new $a({width:e,height:t,fill:`#ffffff`,selectable:!1,evented:!1,left:0,top:0,shadow:new Lr({color:`rgba(0,0,0,0.3)`,blur:20,offsetX:0,offsetY:4})});return a.customId=`__artboard__`,i.add(a),d.current=a,i.on(`selection:created`,p),i.on(`selection:updated`,p),i.on(`selection:cleared`,()=>r([],null)),i.on(`object:modified`,m),i.on(`object:added`,f),i.on(`object:removed`,f),requestAnimationFrame(()=>h()),()=>{i.dispose(),l.current=null,d.current=null}},[]),(0,V.useEffect)(()=>{let n=d.current;n&&(n.set({width:e,height:t}),h())},[e,t,h]),(0,V.useEffect)(()=>{let e=u.current;if(!e)return;let t=new ResizeObserver(()=>{requestAnimationFrame(()=>h())});return t.observe(e),()=>t.disconnect()},[h]),(0,V.useEffect)(()=>{let e=l.current;if(!e)return;let t=fl(n);e.isDrawingMode=t.isDrawingMode,e.selection=t.selection,e.defaultCursor=t.defaultCursor,e.hoverCursor=t.hoverCursor,t.pencilBrush&&(e.freeDrawingBrush=new Ns(e),e.freeDrawingBrush.color=t.pencilBrush.color,e.freeDrawingBrush.width=t.pencilBrush.width),e.requestRenderAll()},[n]),(0,V.useEffect)(()=>{let e=l.current;if(!e||n===`select`||n===`draw`||n===`image`)return;let t=!1,r=0,a=0,o=null,s=s=>{let c=s.scenePoint;if(t=!0,r=c.x,a=c.y,n===`text`){let n=new uc(`Type here`,{left:c.x,top:c.y,width:200,fontSize:24,fontFamily:`Inter, sans-serif`,fill:`#000000`});ll(n),e.add(n),e.setActiveObject(n),n.enterEditing(),i(),t=!1;return}o=ul(n,c),o&&(ll(o),e.add(o))},c=i=>{if(!t||!o)return;let s=i.scenePoint;dl({activeTool:n,object:o,start:{x:r,y:a},pointer:s}),e.requestRenderAll()},u=()=>{t&&(t=!1,o&&(e.setActiveObject(o),i()),o=null)};return e.on(`mouse:down`,s),e.on(`mouse:move`,c),e.on(`mouse:up`,u),()=>{e.off(`mouse:down`,s),e.off(`mouse:move`,c),e.off(`mouse:up`,u)}},[n,i]),(0,V.useImperativeHandle)(s,()=>({toJSON:()=>{let e=l.current;return e?JSON.stringify(e.toObject([`customId`,`customName`])):`{}`},loadJSON:async e=>{let t=l.current;t&&(await t.loadFromJSON(e),t.requestRenderAll(),f())},exportPNG:(n=1)=>{let r=l.current,i=d.current;return!r||!i?``:r.toDataURL({format:`png`,multiplier:n,left:i.left,top:i.top,width:e,height:t})},exportSVG:()=>{let e=l.current;return e?e.toSVG():``},getCanvas:()=>l.current,addObject:e=>{let t=l.current;t&&(ll(e),t.add(e),t.setActiveObject(e),i())},fitToView:h,applyGeneratedLayout:e=>{let t=l.current;if(!t)return;let n=t.getObjects();for(let e of n)e.customId!==`__artboard__`&&t.remove(e);for(let n of e){let e=sl(n),r=e;n.customId&&(r.customId=n.customId),n.customName&&(r.customName=n.customName),ll(e),t.add(e)}t.discardActiveObject(),t.requestRenderAll(),i(),f()}})),(0,$.jsx)(`div`,{ref:u,className:`relative flex-1 overflow-hidden bg-muted/35 dark:bg-background`,children:(0,$.jsx)(`canvas`,{ref:c})})}),ml=r(),hl=[{id:`rect`,icon:v,label:`Rectangle`},{id:`circle`,icon:P,label:`Circle`},{id:`line`,icon:w,label:`Line`},{id:`polygon`,icon:L,label:`Rounded Rectangle`}],gl=(0,V.memo)(function(e){let t=(0,ml.c)(17),{activeTool:n,onToolChange:r}=e,[a,o]=(0,V.useState)(!1),s=hl.some(e=>e.id===n),c;t[0]===n?c=t[1]:(c=hl.find(e=>e.id===n),t[0]=n,t[1]=c);let l=c?.icon??v,u=`inline-flex h-7 items-center gap-0.5 rounded-md px-1.5 text-muted-foreground hover:bg-accent hover:text-foreground ${s?`bg-accent text-foreground`:``}`,d;t[2]===l?d=t[3]:(d=(0,$.jsx)(l,{className:`size-3.5`}),t[2]=l,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(i,{className:`size-2.5`}),t[4]=f):f=t[4];let p;t[5]!==u||t[6]!==d?(p=(0,$.jsxs)(_,{className:u,"aria-label":`Shape tools`,children:[d,f]}),t[5]=u,t[6]=d,t[7]=p):p=t[7];let m;t[8]!==n||t[9]!==r?(m=hl.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{onClick:()=>{r(e.id),o(!1)},className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs hover:bg-accent ${n===e.id?`bg-accent text-foreground`:`text-muted-foreground`}`,children:[(0,$.jsx)(t,{className:`size-3.5`}),e.label]},e.id)}),t[8]=n,t[9]=r,t[10]=m):m=t[10];let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(k,{side:`top`,className:`w-36 p-1`,children:m}),t[11]=m,t[12]=h);let g;return t[13]!==a||t[14]!==p||t[15]!==h?(g=(0,$.jsxs)(E,{open:a,onOpenChange:o,children:[p,h]}),t[13]=a,t[14]=p,t[15]=h,t[16]=g):g=t[16],g}),_l=(0,V.memo)(function(e){let t=(0,ml.c)(77),{activeTool:n,onToolChange:r,canUndo:i,canRedo:l,onUndo:u,onRedo:d,zoomLevel:f,onZoomIn:p,onZoomOut:m,onFitToView:h,canvasRef:g,onCanvasModified:_}=e,v=(0,V.useRef)(null),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>{v.current?.click()},t[0]=y):y=t[0];let b=y,x;t[1]!==g||t[2]!==_?(x=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.addEventListener(`load`,async()=>{let e=n.result,t=await xc.fromURL(e);t.scaleToWidth(300),g.current?.addObject(t),_()}),n.readAsDataURL(t),e.target.value=``},t[1]=g,t[2]=_,t[3]=x):x=t[3];let S=x,C;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(C={id:`select`,icon:(0,$.jsx)(re,{className:`size-3.5`}),label:`Select (V)`},t[4]=C):C=t[4];let w;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(w=[C,{id:`text`,icon:(0,$.jsx)(a,{className:`size-3.5`}),label:`Text (T)`}],t[5]=w):w=t[5];let T=w,E,D;t[6]!==n||t[7]!==r?(E=T.map(e=>(0,$.jsxs)(c,{children:[(0,$.jsx)(s,{render:(0,$.jsx)(F,{pressed:n===e.id,onPressedChange:()=>r(e.id),"aria-label":e.label,size:`xs`,variant:`default`,children:e.icon})}),(0,$.jsx)(o,{side:`top`,children:e.label})]},e.id)),D=(0,$.jsx)(gl,{activeTool:n,onToolChange:r}),t[6]=n,t[7]=r,t[8]=E,t[9]=D):(E=t[8],D=t[9]);let O=n===`image`,k;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(R,{className:`size-3.5`}),t[10]=k):k=t[10];let A;t[11]===O?A=t[12]:(A=(0,$.jsx)(s,{render:(0,$.jsx)(F,{pressed:O,onPressedChange:b,"aria-label":`Image`,size:`xs`,variant:`default`,children:k})}),t[11]=O,t[12]=A);let M;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(o,{side:`top`,children:`Upload Image`}),t[13]=M):M=t[13];let N;t[14]===A?N=t[15]:(N=(0,$.jsxs)(c,{children:[A,M]}),t[14]=A,t[15]=N);let P=n===`draw`,I;t[16]===r?I=t[17]:(I=()=>r(`draw`),t[16]=r,t[17]=I);let ee;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(ie,{className:`size-3.5`}),t[18]=ee):ee=t[18];let L;t[19]!==P||t[20]!==I?(L=(0,$.jsx)(s,{render:(0,$.jsx)(F,{pressed:P,onPressedChange:I,"aria-label":`Draw`,size:`xs`,variant:`default`,children:ee})}),t[19]=P,t[20]=I,t[21]=L):L=t[21];let z;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(o,{side:`top`,children:`Freehand Draw (D)`}),t[22]=z):z=t[22];let B;t[23]===L?B=t[24]:(B=(0,$.jsxs)(c,{children:[L,z]}),t[23]=L,t[24]=B);let ne;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),t[25]=ne):ne=t[25];let oe=!i,se;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(j,{className:`size-3.5`}),t[26]=se):se=t[26];let ue;t[27]!==u||t[28]!==oe?(ue=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:u,disabled:oe,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent`,"aria-label":`Undo`,children:se})}),t[27]=u,t[28]=oe,t[29]=ue):ue=t[29];let de;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(o,{side:`top`,children:`Undo (Ctrl+Z)`}),t[30]=de):de=t[30];let fe;t[31]===ue?fe=t[32]:(fe=(0,$.jsxs)(c,{children:[ue,de]}),t[31]=ue,t[32]=fe);let pe=!l,me;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(me=(0,$.jsx)(ae,{className:`size-3.5`}),t[33]=me):me=t[33];let he;t[34]!==d||t[35]!==pe?(he=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:d,disabled:pe,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-30 disabled:hover:bg-transparent`,"aria-label":`Redo`,children:me})}),t[34]=d,t[35]=pe,t[36]=he):he=t[36];let ge;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,$.jsx)(o,{side:`top`,children:`Redo (Ctrl+Shift+Z)`}),t[37]=ge):ge=t[37];let _e;t[38]===he?_e=t[39]:(_e=(0,$.jsxs)(c,{children:[he,ge]}),t[38]=he,t[39]=_e);let ve;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,$.jsx)(`div`,{className:`flex-1`}),t[40]=ve):ve=t[40];let ye;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(le,{className:`size-3.5`}),t[41]=ye):ye=t[41];let be;t[42]===m?be=t[43]:(be=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:m,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Zoom out`,children:ye})}),t[42]=m,t[43]=be);let xe;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,$.jsx)(o,{side:`top`,children:`Zoom Out`}),t[44]=xe):xe=t[44];let Se;t[45]===be?Se=t[46]:(Se=(0,$.jsxs)(c,{children:[be,xe]}),t[45]=be,t[46]=Se);let H;t[47]===f?H=t[48]:(H=Math.round(f*100),t[47]=f,t[48]=H);let Ce;t[49]===H?Ce=t[50]:(Ce=(0,$.jsxs)(`span`,{className:`min-w-[3rem] text-center text-xs tabular-nums text-muted-foreground`,children:[H,`%`]}),t[49]=H,t[50]=Ce);let U;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,$.jsx)(ce,{className:`size-3.5`}),t[51]=U):U=t[51];let we;t[52]===p?we=t[53]:(we=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:p,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Zoom in`,children:U})}),t[52]=p,t[53]=we);let Te;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(Te=(0,$.jsx)(o,{side:`top`,children:`Zoom In`}),t[54]=Te):Te=t[54];let Ee;t[55]===we?Ee=t[56]:(Ee=(0,$.jsxs)(c,{children:[we,Te]}),t[55]=we,t[56]=Ee);let De;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(De=(0,$.jsx)(te,{className:`size-3.5`}),t[57]=De):De=t[57];let Oe;t[58]===h?Oe=t[59]:(Oe=(0,$.jsx)(s,{render:(0,$.jsx)(`button`,{onClick:h,className:`inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,"aria-label":`Fit to view`,children:De})}),t[58]=h,t[59]=Oe);let ke;t[60]===Symbol.for(`react.memo_cache_sentinel`)?(ke=(0,$.jsx)(o,{side:`top`,children:`Fit to View`}),t[60]=ke):ke=t[60];let Ae;t[61]===Oe?Ae=t[62]:(Ae=(0,$.jsxs)(c,{children:[Oe,ke]}),t[61]=Oe,t[62]=Ae);let je;t[63]===S?je=t[64]:(je=(0,$.jsx)(`input`,{ref:v,type:`file`,accept:`image/*`,className:`hidden`,onChange:S}),t[63]=S,t[64]=je);let Me;return t[65]!==N||t[66]!==B||t[67]!==fe||t[68]!==_e||t[69]!==Se||t[70]!==Ce||t[71]!==Ee||t[72]!==Ae||t[73]!==je||t[74]!==E||t[75]!==D?(Me=(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-t border-border bg-card px-2 py-1.5`,children:[E,D,N,B,ne,fe,_e,ve,Se,Ce,Ee,Ae,je]}),t[65]=N,t[66]=B,t[67]=fe,t[68]=_e,t[69]=Se,t[70]=Ce,t[71]=Ee,t[72]=Ae,t[73]=je,t[74]=E,t[75]=D,t[76]=Me):Me=t[76],Me});function vl(e){switch(e){case`textbox`:case`i-text`:return a;case`rect`:return v;case`circle`:case`ellipse`:return P;case`image`:return z;case`path`:return ie;default:return v}}var yl=(0,V.memo)(function(e){let t=(0,ml.c)(12),{layers:n,selectedObjectIds:r,onLayerSelect:i,onLayerVisibilityToggle:a}=e;if(n.length===0){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`No objects on canvas`}),t[0]=e):e=t[0],e}let o;if(t[1]!==n||t[2]!==i||t[3]!==a||t[4]!==r){let e;t[6]!==i||t[7]!==a||t[8]!==r?(e=e=>{let t=vl(e.type),n=r.includes(e.id);return(0,$.jsxs)(`div`,{onClick:()=>i(e.id),className:`flex cursor-pointer items-center gap-1.5 rounded px-1.5 py-1 text-[10px] ${n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-accent hover:text-foreground`}`,children:[(0,$.jsx)(`button`,{onClick:t=>{t.stopPropagation(),a(e.id)},className:`inline-flex size-4 items-center justify-center rounded hover:bg-accent`,children:e.visible?(0,$.jsx)(b,{className:`size-2.5`}):(0,$.jsx)(m,{className:`size-2.5 opacity-40`})}),(0,$.jsx)(t,{className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name})]},e.id)},t[6]=i,t[7]=a,t[8]=r,t[9]=e):e=t[9],o=[...n].toReversed().map(e),t[1]=n,t[2]=i,t[3]=a,t[4]=r,t[5]=o}else o=t[5];let s;return t[10]===o?s=t[11]:(s=(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:o}),t[10]=o,t[11]=s),s}),bl=(0,V.memo)(function(e){let t=(0,ml.c)(29),{open:n,properties:r,layers:i,onClose:a,onPropertyChange:o,onLayerSelect:s,onLayerVisibilityToggle:c,onMoveUp:l,onMoveDown:u,onBringToFront:d,onSendToBack:m}=e,h;t[0]===o?h=t[1]:(h=(e,t)=>{let n=Number.parseFloat(t);Number.isNaN(n)||o(e,n)},t[0]=o,t[1]=h);let _=h;if(!n)return null;let v=r?.type===`textbox`||r?.type===`i-text`,y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:`Properties`}),t[2]=y):y=t[2];let b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(C,{className:`size-3`}),t[3]=b):b=t[3];let x;t[4]===a?x=t[5]:(x=(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-2`,children:[y,(0,$.jsx)(`button`,{onClick:a,className:`inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:text-foreground`,children:b})]}),t[4]=a,t[5]=x);let S;t[6]!==_||t[7]!==v||t[8]!==d||t[9]!==u||t[10]!==l||t[11]!==o||t[12]!==m||t[13]!==r?(S=r?(0,$.jsxs)(`div`,{className:`space-y-3 p-3`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Transform`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(xl,{label:`X`,value:r.left,onChange:e=>_(`left`,e)}),(0,$.jsx)(xl,{label:`Y`,value:r.top,onChange:e=>_(`top`,e)}),(0,$.jsx)(xl,{label:`W`,value:r.width,onChange:e=>_(`scaleWidth`,e)}),(0,$.jsx)(xl,{label:`H`,value:r.height,onChange:e=>_(`scaleHeight`,e)}),(0,$.jsx)(xl,{label:`R`,value:r.angle,onChange:e=>_(`angle`,e)})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Appearance`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Sl,{label:`Fill`,value:r.fill??``,onChange:e=>o(`fill`,e)}),(0,$.jsx)(Sl,{label:`Stroke`,value:r.stroke??``,onChange:e=>o(`stroke`,e)}),(0,$.jsx)(xl,{label:`Stroke W`,value:r.strokeWidth,onChange:e=>_(`strokeWidth`,e)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:`Opacity`}),(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:.01,value:r.opacity,onChange:e=>o(`opacity`,Number.parseFloat(e.target.value)),className:`h-1 flex-1 appearance-none rounded-full bg-border accent-primary`}),(0,$.jsxs)(`span`,{className:`w-8 text-right text-[10px] tabular-nums text-muted-foreground`,children:[Math.round(r.opacity*100),`%`]})]})]})]}),v&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Text`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:`Font`}),(0,$.jsx)(`input`,{type:`text`,value:r.fontFamily??`Inter`,onChange:e=>o(`fontFamily`,e.target.value),className:`h-6 flex-1 rounded border border-border bg-background px-1.5 text-[10px] text-foreground`})]}),(0,$.jsx)(xl,{label:`Size`,value:r.fontSize??16,onChange:e=>_(`fontSize`,e)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:`Align`}),(0,$.jsx)(`div`,{className:`flex gap-1`,children:[`left`,`center`,`right`].map(e=>(0,$.jsx)(`button`,{onClick:()=>o(`textAlign`,e),className:`rounded px-1.5 py-0.5 text-[10px] ${r.textAlign===e?`bg-primary text-primary-foreground`:`bg-background text-muted-foreground hover:text-foreground`}`,children:e.charAt(0).toUpperCase()+e.slice(1)},e))})]})]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Order`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Cl,{icon:(0,$.jsx)(g,{className:`size-3`}),label:`Bring to front`,onClick:d}),(0,$.jsx)(Cl,{icon:(0,$.jsx)(p,{className:`size-3`}),label:`Move up`,onClick:l}),(0,$.jsx)(Cl,{icon:(0,$.jsx)(f,{className:`size-3`}),label:`Move down`,onClick:u}),(0,$.jsx)(Cl,{icon:(0,$.jsx)(N,{className:`size-3`}),label:`Send to back`,onClick:m})]})]})]}):null,t[6]=_,t[7]=v,t[8]=d,t[9]=u,t[10]=l,t[11]=o,t[12]=m,t[13]=r,t[14]=S):S=t[14];let w;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`h4`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Layers`}),t[15]=w):w=t[15];let T;t[16]===r?T=t[17]:(T=r?[r.id]:[],t[16]=r,t[17]=T);let E;t[18]!==i||t[19]!==s||t[20]!==c||t[21]!==T?(E=(0,$.jsxs)(`div`,{className:`border-t border-border p-3`,children:[w,(0,$.jsx)(yl,{layers:i,selectedObjectIds:T,onLayerSelect:s,onLayerVisibilityToggle:c})]}),t[18]=i,t[19]=s,t[20]=c,t[21]=T,t[22]=E):E=t[22];let D;t[23]!==S||t[24]!==E?(D=(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[S,E]}),t[23]=S,t[24]=E,t[25]=D):D=t[25];let O;return t[26]!==x||t[27]!==D?(O=(0,$.jsxs)(`div`,{className:`absolute right-0 top-0 z-10 flex h-full w-56 flex-col border-l border-border bg-card`,children:[x,D]}),t[26]=x,t[27]=D,t[28]=O):O=t[28],O});function xl(e){let t=(0,ml.c)(12),{label:n,value:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`label`,{className:`w-5 text-[10px] text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=Math.round(r),t[2]=r,t[3]=o);let s;t[4]===i?s=t[5]:(s=e=>i(e.target.value),t[4]=i,t[5]=s);let c;t[6]!==o||t[7]!==s?(c=(0,$.jsx)(`input`,{type:`number`,value:o,onChange:s,className:`h-6 w-full rounded border border-border bg-background px-1.5 text-[10px] tabular-nums text-foreground`}),t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;return t[9]!==a||t[10]!==c?(l=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[a,c]}),t[9]=a,t[10]=c,t[11]=l):l=t[11],l}function Sl(e){let t=(0,ml.c)(15),{label:n,value:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`label`,{className:`w-12 text-[10px] text-muted-foreground`,children:n}),t[0]=n,t[1]=a);let o=r||`#000000`,s;t[2]===i?s=t[3]:(s=e=>i(e.target.value),t[2]=i,t[3]=s);let c;t[4]!==o||t[5]!==s?(c=(0,$.jsx)(`input`,{type:`color`,value:o,onChange:s,className:`size-5 cursor-pointer rounded border border-border`}),t[4]=o,t[5]=s,t[6]=c):c=t[6];let l=r||`none`,u;t[7]===l?u=t[8]:(u=(0,$.jsx)(`span`,{className:`text-[10px] tabular-nums text-muted-foreground`,children:l}),t[7]=l,t[8]=u);let d;t[9]!==c||t[10]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[c,u]}),t[9]=c,t[10]=u,t[11]=d):d=t[11];let f;return t[12]!==a||t[13]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a,d]}),t[12]=a,t[13]=d,t[14]=f):f=t[14],f}function Cl(e){let t=(0,ml.c)(4),{icon:n,label:r,onClick:i}=e,a;return t[0]!==n||t[1]!==r||t[2]!==i?(a=(0,$.jsx)(`button`,{onClick:i,className:`inline-flex size-7 items-center justify-center rounded border border-border bg-background text-muted-foreground hover:text-foreground`,title:r,children:n}),t[0]=n,t[1]=r,t[2]=i,t[3]=a):a=t[3],a}var wl=(0,V.memo)(function(e){let t=(0,ml.c)(67),{artboardPresetId:n,artboardWidth:r,artboardHeight:a,onSelectPreset:o,onCustomSize:s}=e,[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(String(r)),[f,p]=(0,V.useState)(String(a)),m;t[0]===n?m=t[1]:(m=n?de.get(n):null,t[0]=n,t[1]=m);let h=m,g=h?h.label:`${r} x ${a}`,v,y,b,x,S,C,w,T,D,O,A;if(t[2]!==a||t[3]!==r||t[4]!==f||t[5]!==u||t[6]!==g||t[7]!==s||t[8]!==c){let e=fe(),n;t[20]!==f||t[21]!==u||t[22]!==s?(n=()=>{let e=Number.parseInt(u,10),t=Number.parseInt(f,10);e>0&&t>0&&(s(e,t),l(!1))},t[20]=f,t[21]=u,t[22]=s,t[23]=n):n=t[23],b=n,y=E,D=c,O=l;let o;t[24]===g?o=t[25]:(o=(0,$.jsx)(`span`,{className:`max-w-[140px] truncate`,children:g}),t[24]=g,t[25]=o);let d;t[26]!==a||t[27]!==r?(d=(0,$.jsxs)(`span`,{className:`tabular-nums opacity-60`,children:[r,`x`,a]}),t[26]=a,t[27]=r,t[28]=d):d=t[28];let p;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(i,{className:`size-3`}),t[29]=p):p=t[29],t[30]!==o||t[31]!==d?(A=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:[o,d,p]}),t[30]=o,t[31]=d,t[32]=A):A=t[32],v=k,C=`bottom`,w=`start`,T=`w-64 p-0`,S=`max-h-72 overflow-y-auto p-1`,x=[...e.entries()],t[2]=a,t[3]=r,t[4]=f,t[5]=u,t[6]=g,t[7]=s,t[8]=c,t[9]=v,t[10]=y,t[11]=b,t[12]=x,t[13]=S,t[14]=C,t[15]=w,t[16]=T,t[17]=D,t[18]=O,t[19]=A}else v=t[9],y=t[10],b=t[11],x=t[12],S=t[13],C=t[14],w=t[15],T=t[16],D=t[17],O=t[18],A=t[19];let j;t[33]!==n||t[34]!==o||t[35]!==x?(j=x.map(e=>{let[t,r]=e;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:t}),r.map(e=>(0,$.jsxs)(`button`,{onClick:()=>{o(e),l(!1)},className:`flex w-full items-center justify-between rounded-md px-2 py-1.5 text-xs hover:bg-accent ${n===e.id?`bg-accent text-foreground`:`text-muted-foreground`}`,children:[(0,$.jsx)(`span`,{children:e.label}),(0,$.jsxs)(`span`,{className:`tabular-nums opacity-60`,children:[e.width,`x`,e.height]})]},e.id))]},t)}),t[33]=n,t[34]=o,t[35]=x,t[36]=j):j=t[36];let M;t[37]!==j||t[38]!==S?(M=(0,$.jsx)(`div`,{className:S,children:j}),t[37]=j,t[38]=S,t[39]=M):M=t[39];let N;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Custom Size`}),t[40]=N):N=t[40];let P;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>d(e.target.value),t[41]=P):P=t[41];let F;t[42]===u?F=t[43]:(F=(0,$.jsx)(`input`,{type:`number`,value:u,onChange:P,placeholder:`Width`,className:`h-6 w-20 rounded border border-border bg-background px-1.5 text-[10px] tabular-nums`}),t[42]=u,t[43]=F);let I;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`x`}),t[44]=I):I=t[44];let ee;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>p(e.target.value),t[45]=ee):ee=t[45];let L;t[46]===f?L=t[47]:(L=(0,$.jsx)(`input`,{type:`number`,value:f,onChange:ee,placeholder:`Height`,className:`h-6 w-20 rounded border border-border bg-background px-1.5 text-[10px] tabular-nums`}),t[46]=f,t[47]=L);let R;t[48]===b?R=t[49]:(R=(0,$.jsx)(`button`,{onClick:b,className:`h-6 rounded bg-primary px-2 text-[10px] font-medium text-primary-foreground hover:bg-primary/90`,children:`Apply`}),t[48]=b,t[49]=R);let z;t[50]!==F||t[51]!==L||t[52]!==R?(z=(0,$.jsxs)(`div`,{className:`border-t border-border p-2`,children:[N,(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[F,I,L,R]})]}),t[50]=F,t[51]=L,t[52]=R,t[53]=z):z=t[53];let B;t[54]!==v||t[55]!==M||t[56]!==z||t[57]!==C||t[58]!==w||t[59]!==T?(B=(0,$.jsxs)(v,{side:C,align:w,className:T,children:[M,z]}),t[54]=v,t[55]=M,t[56]=z,t[57]=C,t[58]=w,t[59]=T,t[60]=B):B=t[60];let te;return t[61]!==y||t[62]!==B||t[63]!==D||t[64]!==O||t[65]!==A?(te=(0,$.jsxs)(y,{open:D,onOpenChange:O,children:[A,B]}),t[61]=y,t[62]=B,t[63]=D,t[64]=O,t[65]=A,t[66]=te):te=t[66],te}),Tl=(0,V.memo)(function({canvasRef:e,artboardWidth:t,artboardHeight:n,savedDesigns:r,onSaveDesign:i,onLoadDesign:a,onDeleteDesign:o}){let[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(!1),f=t=>{let n=e.current?.exportPNG(t);n&&pe(n,`design-${Date.now()}.png`),c(!1)},p=()=>{let t=e.current?.exportSVG();t&&me(new Blob([t],{type:`image/svg+xml`}),`design-${Date.now()}.svg`),c(!1)},m=async()=>{let r=e.current?.exportPNG(2);if(!r)return;let{jsPDF:i}=await d(async()=>{let{jsPDF:e}=await import(`./jspdf.es.min-Hx4pHu4X.js`);return{jsPDF:e}},__vite__mapDeps([0,1,2,3])),a=new i({orientation:t>n?`landscape`:`portrait`,unit:`px`,format:[t,n]});a.addImage(r,`PNG`,0,0,t,n),a.save(`design-${Date.now()}.pdf`),c(!1)},h=()=>{let t=e.current?.toJSON();t&&(i(`design-${Date.now()}`,`Design ${new Date().toLocaleString()}`,t),c(!1))},g=e=>{a(e),c(!1),u(!1)},v=Object.entries(r).toSorted(([,e],[,t])=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime());return(0,$.jsxs)(E,{open:s,onOpenChange:e=>{c(e),e||u(!1)},children:[(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md bg-success px-2.5 py-1 text-xs font-medium text-white hover:bg-success`,children:[(0,$.jsx)(M,{className:`size-3`}),`Export`]}),(0,$.jsx)(k,{side:`bottom`,align:`end`,className:`w-52 p-1`,children:l?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`button`,{onClick:()=>u(!1),className:`mb-1 w-full rounded px-2 py-1 text-left text-[10px] text-muted-foreground hover:bg-accent`,children:`← Back`}),v.map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1 rounded px-1 py-0.5 hover:bg-accent`,children:[(0,$.jsx)(`button`,{onClick:()=>g(t.json),className:`flex-1 truncate px-1 py-1 text-left text-xs text-foreground`,children:t.name}),(0,$.jsx)(`button`,{onClick:()=>o(e),className:`inline-flex size-5 items-center justify-center rounded text-muted-foreground hover:text-destructive`,children:(0,$.jsx)(oe,{className:`size-3`})})]},e))]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(El,{label:`Export`,children:[(0,$.jsx)(Dl,{icon:(0,$.jsx)(z,{className:`size-3.5`}),label:`PNG (1x)`,onClick:()=>f(1)}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(z,{className:`size-3.5`}),label:`PNG (2x)`,onClick:()=>f(2)}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(I,{className:`size-3.5`}),label:`SVG`,onClick:p}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(x,{className:`size-3.5`}),label:`PDF`,onClick:()=>void m()})]}),(0,$.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,$.jsxs)(El,{label:`Design`,children:[(0,$.jsx)(Dl,{icon:(0,$.jsx)(y,{className:`size-3.5`}),label:`Save Design`,onClick:h}),(0,$.jsx)(Dl,{icon:(0,$.jsx)(ee,{className:`size-3.5`}),label:`Load Design (${v.length})`,onClick:()=>u(!0),disabled:v.length===0})]})]})})]})});function El(e){let t=(0,ml.c)(5),{label:n,children:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`div`,{className:`px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:n}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,$.jsxs)(`div`,{children:[i,r]}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a}function Dl(e){let t=(0,ml.c)(5),{icon:n,label:r,onClick:i,disabled:a}=e,o;return t[0]!==a||t[1]!==n||t[2]!==r||t[3]!==i?(o=(0,$.jsxs)(`button`,{onClick:i,disabled:a,className:`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40`,children:[n,r]}),t[0]=a,t[1]=n,t[2]=r,t[3]=i,t[4]=o):o=t[4],o}var Ol=(0,V.memo)(function(e){let t=(0,ml.c)(26),{canvasRef:n,artboardWidth:r,artboardHeight:i,brandKit:a,onCanvasModified:o}=e,[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(``),d;t[0]!==i||t[1]!==r||t[2]!==a||t[3]!==n||t[4]!==o||t[5]!==l?(d=()=>{let e=l.trim();if(!e)return;let t=S(e,r,i,a);n.current?.applyGeneratedLayout(t.objects),o(),u(``),c(!1)},t[0]=i,t[1]=r,t[2]=a,t[3]=n,t[4]=o,t[5]=l,t[6]=d):d=t[6];let f=d,p;t[7]===f?p=t[8]:(p=e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),f())},t[7]=f,t[8]=p);let m=p,h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary/10 px-2.5 py-1 text-xs font-medium text-primary hover:bg-primary/20`,children:[(0,$.jsx)(se,{className:`size-3`}),`Quick Create`]}),t[9]=h):h=t[9];let g,v;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`div`,{className:`mb-2 text-xs font-semibold text-foreground`,children:`Generate Design`}),v=(0,$.jsx)(`p`,{className:`mb-3 text-[10px] text-muted-foreground`,children:`Describe what you want and we'll generate a canvas layout for you.`}),t[10]=g,t[11]=v):(g=t[10],v=t[11]);let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>u(e.target.value),t[12]=y):y=t[12];let b;t[13]!==m||t[14]!==l?(b=(0,$.jsx)(`textarea`,{value:l,onChange:y,onKeyDown:m,placeholder:`e.g. Bold sale announcement for Instagram...`,rows:3,className:`mb-2 w-full resize-none rounded-md border border-border bg-background px-2.5 py-2 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary`,autoFocus:!0}),t[13]=m,t[14]=l,t[15]=b):b=t[15];let x;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`Press Enter to generate`}),t[16]=x):x=t[16];let C=!l.trim(),w;t[17]!==f||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[x,(0,$.jsx)(`button`,{onClick:f,disabled:C,className:`rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:`Generate`})]}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]!==w||t[21]!==b?(T=(0,$.jsxs)(k,{side:`bottom`,align:`start`,className:`w-80 p-3`,children:[g,v,b,w]}),t[20]=w,t[21]=b,t[22]=T):T=t[22];let D;return t[23]!==s||t[24]!==T?(D=(0,$.jsxs)(E,{open:s,onOpenChange:c,children:[h,T]}),t[23]=s,t[24]=T,t[25]=D):D=t[25],D}),kl={social:`Social Media`,business:`Business`,marketing:`Marketing`,presentation:`Presentations`},Al=(0,V.memo)(function(e){let t=(0,ml.c)(50),{canvasRef:n,brandKit:r,onCanvasModified:i,onSelectPreset:a}=e,[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),u,d,f,p,m,g,v,y,b,x,C;if(t[0]!==c||t[1]!==r||t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o){let e=h(),w=[...e.keys()],D=c?e.get(c)??[]:T,O;t[17]!==r||t[18]!==n||t[19]!==i||t[20]!==a?(O=e=>{let t=de.get(e.presetId);t&&a(t);let o=t?.width??1080,c=t?.height??1080,l=S(e.previewPrompt,o,c,r);requestAnimationFrame(()=>{n.current?.applyGeneratedLayout(l.objects),i()}),s(!1)},t[17]=r,t[18]=n,t[19]=i,t[20]=a,t[21]=O):O=t[21];let A=O;d=E,b=o,x=s,t[22]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,$.jsx)(B,{className:`size-3`}),`Templates`]}),t[22]=C):C=t[22],u=k,m=`bottom`,g=`start`,v=`w-80 p-0`;let j;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>l(null),t[23]=j):j=t[23];let M=`rounded-md px-2 py-1 text-[10px] font-medium ${c===null?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground`}`,N;t[24]===M?N=t[25]:(N=(0,$.jsx)(`button`,{onClick:j,className:M,children:`All`}),t[24]=M,t[25]=N);let P;t[26]!==c||t[27]!==w?(P=w.map(e=>(0,$.jsx)(`button`,{onClick:()=>l(e),className:`rounded-md px-2 py-1 text-[10px] font-medium ${c===e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground`}`,children:kl[e]??e},e)),t[26]=c,t[27]=w,t[28]=P):P=t[28],t[29]!==N||t[30]!==P?(y=(0,$.jsxs)(`div`,{className:`flex gap-1 border-b border-border px-2 py-1.5`,children:[N,P]}),t[29]=N,t[30]=P,t[31]=y):y=t[31],f=`grid max-h-64 grid-cols-2 gap-1.5 overflow-y-auto p-2`;let F;t[32]===A?F=t[33]:(F=e=>{let t=de.get(e.presetId);return(0,$.jsxs)(`button`,{onClick:()=>A(e),className:`group flex flex-col rounded-lg border border-border p-2 text-left hover:border-primary/50 hover:bg-accent/50`,children:[(0,$.jsx)(`div`,{className:`mb-1.5 h-12 w-full rounded-md`,style:{background:e.style===`bold`?`linear-gradient(135deg, #1f2937, #374151)`:e.style===`gradient`?`linear-gradient(135deg, #4f46e5, #818cf8)`:e.style===`centered`?`linear-gradient(135deg, #fef3c7, #fde68a)`:e.style===`split`?`linear-gradient(90deg, #0ea5e9 45%, #f8fafc 45%)`:`#f8fafc`}}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-foreground group-hover:text-primary`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:t?.label??e.presetId})]},e.id)},t[32]=A,t[33]=F),p=D.map(F),t[0]=c,t[1]=r,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=g,t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=C}else u=t[6],d=t[7],f=t[8],p=t[9],m=t[10],g=t[11],v=t[12],y=t[13],b=t[14],x=t[15],C=t[16];let w;t[34]!==f||t[35]!==p?(w=(0,$.jsx)(`div`,{className:f,children:p}),t[34]=f,t[35]=p,t[36]=w):w=t[36];let D;t[37]!==u||t[38]!==w||t[39]!==m||t[40]!==g||t[41]!==v||t[42]!==y?(D=(0,$.jsxs)(u,{side:m,align:g,className:v,children:[y,w]}),t[37]=u,t[38]=w,t[39]=m,t[40]=g,t[41]=v,t[42]=y,t[43]=D):D=t[43];let O;return t[44]!==d||t[45]!==D||t[46]!==b||t[47]!==x||t[48]!==C?(O=(0,$.jsxs)(d,{open:b,onOpenChange:x,children:[C,D]}),t[44]=d,t[45]=D,t[46]=b,t[47]=x,t[48]=C,t[49]=O):O=t[49],O});function jl(e){let t=(0,ml.c)(13),{label:n,value:r,onChange:i}=e,a;t[0]===i?a=t[1]:(a=e=>i(e.target.value),t[0]=i,t[1]=a);let o;t[2]!==a||t[3]!==r?(o=(0,$.jsx)(`input`,{type:`color`,value:r,onChange:a,className:`size-5 cursor-pointer rounded border border-border`}),t[2]=a,t[3]=r,t[4]=o):o=t[4];let s;t[5]===n?s=t[6]:(s=(0,$.jsx)(`span`,{className:`flex-1 text-[10px] text-muted-foreground`,children:n}),t[5]=n,t[6]=s);let c;t[7]===r?c=t[8]:(c=(0,$.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground/60`,children:r}),t[7]=r,t[8]=c);let l;return t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[o,s,c]}),t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}var Ml=[`Inter, sans-serif`,`Georgia, serif`,`Menlo, monospace`,`system-ui, sans-serif`,`Helvetica, Arial, sans-serif`,`Times New Roman, serif`],Nl=(0,V.memo)(function(e){let t=(0,ml.c)(70),{brandKit:n,onUpdate:r,onReset:i}=e,[a,o]=(0,V.useState)(!1),s;t[0]===r?s=t[1]:(s=(e,t)=>{r({[e]:t})},t[0]=r,t[1]=s);let c=s,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsxs)(_,{className:`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-accent hover:text-foreground`,children:[(0,$.jsx)(D,{className:`size-3`}),`Brand`]}),t[2]=l):l=t[2];let u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:`Brand Kit`}),t[3]=u):u=t[3];let d;t[4]===i?d=t[5]:(d=(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[u,(0,$.jsx)(`button`,{onClick:i,className:`text-[10px] text-muted-foreground hover:text-foreground`,children:`Reset`})]}),t[4]=i,t[5]=d);let f;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Colors`}),t[6]=f):f=t[6];let p;t[7]===c?p=t[8]:(p=e=>c(`primaryColor`,e),t[7]=c,t[8]=p);let m;t[9]!==n.primaryColor||t[10]!==p?(m=(0,$.jsx)(jl,{label:`Primary`,value:n.primaryColor,onChange:p}),t[9]=n.primaryColor,t[10]=p,t[11]=m):m=t[11];let h;t[12]===c?h=t[13]:(h=e=>c(`secondaryColor`,e),t[12]=c,t[13]=h);let g;t[14]!==n.secondaryColor||t[15]!==h?(g=(0,$.jsx)(jl,{label:`Secondary`,value:n.secondaryColor,onChange:h}),t[14]=n.secondaryColor,t[15]=h,t[16]=g):g=t[16];let v;t[17]===c?v=t[18]:(v=e=>c(`accentColor`,e),t[17]=c,t[18]=v);let y;t[19]!==n.accentColor||t[20]!==v?(y=(0,$.jsx)(jl,{label:`Accent`,value:n.accentColor,onChange:v}),t[19]=n.accentColor,t[20]=v,t[21]=y):y=t[21];let b;t[22]===c?b=t[23]:(b=e=>c(`backgroundColor`,e),t[22]=c,t[23]=b);let x;t[24]!==n.backgroundColor||t[25]!==b?(x=(0,$.jsx)(jl,{label:`Background`,value:n.backgroundColor,onChange:b}),t[24]=n.backgroundColor,t[25]=b,t[26]=x):x=t[26];let S;t[27]===c?S=t[28]:(S=e=>c(`textColor`,e),t[27]=c,t[28]=S);let C;t[29]!==n.textColor||t[30]!==S?(C=(0,$.jsx)(jl,{label:`Text`,value:n.textColor,onChange:S}),t[29]=n.textColor,t[30]=S,t[31]=C):C=t[31];let w;t[32]!==y||t[33]!==x||t[34]!==C||t[35]!==m||t[36]!==g?(w=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f,m,g,y,x,C]}),t[32]=y,t[33]=x,t[34]=C,t[35]=m,t[36]=g,t[37]=w):w=t[37];let T;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,children:`Fonts`}),t[38]=T):T=t[38];let O;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(`span`,{className:`mb-1 block text-[10px] text-muted-foreground`,children:`Body Font`}),t[39]=O):O=t[39];let A=n.fontFamily,j;t[40]===r?j=t[41]:(j=e=>r({fontFamily:e.target.value}),t[40]=r,t[41]=j);let M;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(M=Ml.map(Pl),t[42]=M):M=t[42];let N;t[43]!==n.fontFamily||t[44]!==j?(N=(0,$.jsxs)(`label`,{className:`block`,children:[O,(0,$.jsx)(`select`,{value:A,onChange:j,className:`h-6 w-full rounded border border-border bg-background px-1.5 text-[10px]`,children:M})]}),t[43]=n.fontFamily,t[44]=j,t[45]=N):N=t[45];let P;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(`span`,{className:`mb-1 block text-[10px] text-muted-foreground`,children:`Heading Font`}),t[46]=P):P=t[46];let F=n.headingFontFamily,I;t[47]===r?I=t[48]:(I=e=>r({headingFontFamily:e.target.value}),t[47]=r,t[48]=I);let ee;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ee=Ml.map(Fl),t[49]=ee):ee=t[49];let L;t[50]!==n.headingFontFamily||t[51]!==I?(L=(0,$.jsxs)(`label`,{className:`block`,children:[P,(0,$.jsx)(`select`,{value:F,onChange:I,className:`h-6 w-full rounded border border-border bg-background px-1.5 text-[10px]`,children:ee})]}),t[50]=n.headingFontFamily,t[51]=I,t[52]=L):L=t[52];let R;t[53]!==N||t[54]!==L?(R=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[T,N,L]}),t[53]=N,t[54]=L,t[55]=R):R=t[55];let z;t[56]!==n.accentColor||t[57]!==n.backgroundColor||t[58]!==n.primaryColor||t[59]!==n.secondaryColor||t[60]!==n.textColor?(z=(0,$.jsx)(`div`,{className:`mt-3 flex gap-1 rounded-md border border-border p-1.5`,children:[n.primaryColor,n.secondaryColor,n.accentColor,n.backgroundColor,n.textColor].map(Il)}),t[56]=n.accentColor,t[57]=n.backgroundColor,t[58]=n.primaryColor,t[59]=n.secondaryColor,t[60]=n.textColor,t[61]=z):z=t[61];let B;t[62]!==w||t[63]!==R||t[64]!==z||t[65]!==d?(B=(0,$.jsxs)(k,{side:`bottom`,align:`end`,className:`w-64 p-3`,children:[d,w,R,z]}),t[62]=w,t[63]=R,t[64]=z,t[65]=d,t[66]=B):B=t[66];let te;return t[67]!==a||t[68]!==B?(te=(0,$.jsxs)(E,{open:a,onOpenChange:o,children:[l,B]}),t[67]=a,t[68]=B,t[69]=te):te=t[69],te});function Pl(e){return(0,$.jsx)(`option`,{value:e,children:e.split(`,`)[0]},e)}function Fl(e){return(0,$.jsx)(`option`,{value:e,children:e.split(`,`)[0]},e)}function Il(e){return(0,$.jsx)(`div`,{className:`h-4 flex-1 rounded-sm`,style:{backgroundColor:e}},e)}var Ll=(0,V.memo)(function({onClose:e}){let t=(0,V.useRef)(null),n=(0,V.useRef)(new u(()=>{let e=t.current?.toJSON();e&&A.getState().pushHistorySnapshot(e)},{wait:500}));(0,V.useEffect)(()=>{let e=n.current;return()=>{e.cancel()}},[]);let{activeTool:r,artboardPresetId:i,artboardWidth:a,artboardHeight:o,selectedObjectProperties:s,propertiesPanelOpen:c,historyIndex:l,historyStack:d,layers:f,zoomLevel:p,savedDesigns:m,brandKit:h,setActiveTool:g,setArtboard:_,setSelectedObjects:v,clearSelection:y,setPropertiesPanelOpen:b,setLayers:x,setZoomLevel:w,undo:T,redo:E,resetHistory:D,saveDesign:k,deleteDesign:j,updateBrandKit:M,setBrandKit:N}=A();(0,V.useEffect)(()=>{let e=setTimeout(()=>{let e=t.current?.toJSON();e&&A.getState().pushHistorySnapshot(e)},100);return()=>clearTimeout(e)},[]),(0,V.useEffect)(()=>{let e=A.subscribe((e,n)=>{if(e.pendingGeneratePrompt&&e.pendingGeneratePrompt!==n.pendingGeneratePrompt){let e=A.getState().consumePendingGenerate();if(e&&t.current){let n=S(e,a,o,h);t.current.applyGeneratedLayout(n.objects)}}}),n=A.getState().consumePendingGenerate();return n&&t.current&&requestAnimationFrame(()=>{let e=S(n,a,o,h);t.current?.applyGeneratedLayout(e.objects)}),e},[a,o,h]);let P=(0,V.useCallback)(()=>{n.current.maybeExecute()},[]),F=(0,V.useCallback)(e=>{g(e)},[g]),I=(0,V.useCallback)(e=>{_(e.id,e.width,e.height),D()},[_,D]),ee=(0,V.useCallback)((e,t)=>{_(null,e,t),D()},[_,D]),L=(0,V.useCallback)(()=>{let e=T();e&&t.current?.loadJSON(e)},[T]),R=(0,V.useCallback)(()=>{let e=E();e&&t.current?.loadJSON(e)},[E]),z=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=ge(p),r=e.viewportTransform;r[0]=n,r[3]=n,e.setViewportTransform(r),w(n),e.requestRenderAll()},[p,w]),B=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=_e(p),r=e.viewportTransform;r[0]=n,r[3]=n,e.setViewportTransform(r),w(n),e.requestRenderAll()},[p,w]),te=(0,V.useCallback)(()=>{t.current?.fitToView()},[]),re=(0,V.useCallback)((e,n)=>{let r=t.current?.getCanvas();if(!r)return;let i=r.getActiveObject();if(!i)return;if(e===`scaleWidth`){let e=i.width??1;i.set(`scaleX`,n/e)}else if(e===`scaleHeight`){let e=i.height??1;i.set(`scaleY`,n/e)}else i.set(e,n);i.setCoords(),r.requestRenderAll(),P();let a=A.getState().selectedObjectProperties;if(a){let t={...a,[e===`scaleWidth`?`width`:e===`scaleHeight`?`height`:e]:n};v([a.id],t)}},[P,v]),ie=(0,V.useCallback)(e=>{let n=t.current?.getCanvas();if(!n)return;let r=n.getObjects().find(t=>t.customId===e);r&&(n.setActiveObject(r),n.requestRenderAll())},[]),ae=(0,V.useCallback)(e=>{let n=t.current?.getCanvas();if(!n)return;let r=n.getObjects().find(t=>t.customId===e);if(r){r.visible=!r.visible,n.requestRenderAll();let t=f.map(t=>t.id===e?{...t,visible:!t.visible}:t);x(t)}},[f,x]),oe=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&(e.bringObjectForward(n),e.requestRenderAll(),P())},[P]),se=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&(e.sendObjectBackwards(n),e.requestRenderAll(),P())},[P]),ce=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&(e.bringObjectToFront(n),e.requestRenderAll(),P())},[P]),le=(0,V.useCallback)(()=>{let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();if(n){let t=e.getObjects().findIndex(e=>e.customId===`__artboard__`);e.moveObjectTo(n,t+1),e.requestRenderAll(),P()}},[P]),ue=(0,V.useCallback)(async e=>{await t.current?.loadJSON(e),D();let n=t.current?.toJSON();n&&A.getState().pushHistorySnapshot(n)},[D]),de=(0,V.useCallback)((e,t,n)=>{k(e,t,n)},[k]);(0,V.useEffect)(()=>{let e=e=>{if(!(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement)){if(!e.metaKey&&!e.ctrlKey)switch(e.key.toLowerCase()){case`v`:g(`select`);return;case`t`:g(`text`);return;case`r`:g(`rect`);return;case`d`:g(`draw`);return}if((e.metaKey||e.ctrlKey)&&e.key===`z`&&(e.preventDefault(),e.shiftKey?R():L()),e.key===`Delete`||e.key===`Backspace`){let e=t.current?.getCanvas();if(!e)return;let n=e.getActiveObject();n&&n.customId!==`__artboard__`&&(e.remove(n),y(),P())}}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g,L,R,y,P]);let fe=l>0,pe=l<d.length-1;return(0,$.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:`Canvas`}),(0,$.jsx)(`div`,{className:`mx-1 h-4 w-px bg-border`}),(0,$.jsx)(Ol,{canvasRef:t,artboardWidth:a,artboardHeight:o,brandKit:h,onCanvasModified:P}),(0,$.jsx)(Al,{canvasRef:t,brandKit:h,onCanvasModified:P,onSelectPreset:I}),(0,$.jsx)(Nl,{brandKit:h,onUpdate:M,onReset:()=>N(O)}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(wl,{artboardPresetId:i,artboardWidth:a,artboardHeight:o,onSelectPreset:I,onCustomSize:ee}),(0,$.jsx)(Tl,{canvasRef:t,artboardWidth:a,artboardHeight:o,savedDesigns:m,onSaveDesign:de,onLoadDesign:e=>void ue(e),onDeleteDesign:j}),e?(0,$.jsx)(`button`,{onClick:e,className:`inline-flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(C,{className:`size-3.5`})}):null]}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 flex-1`,children:[f.length===0&&(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 text-center`,children:[(0,$.jsx)(ne,{className:`size-7 text-muted-foreground/20`}),(0,$.jsx)(`p`,{className:`text-[12px] text-muted-foreground/35`,children:`Use Quick Create or Templates to start designing.`})]}),(0,$.jsx)(pl,{ref:t,artboardWidth:a,artboardHeight:o,activeTool:r,onSelectionChange:v,onCanvasModified:P,onLayersChange:x,onZoomChange:w}),(0,$.jsx)(bl,{open:c,properties:s,layers:f,onClose:()=>b(!1),onPropertyChange:re,onLayerSelect:ie,onLayerVisibilityToggle:ae,onMoveUp:oe,onMoveDown:se,onBringToFront:ce,onSendToBack:le})]}),(0,$.jsx)(_l,{activeTool:r,onToolChange:F,canUndo:fe,canRedo:pe,onUndo:L,onRedo:R,zoomLevel:p,onZoomIn:z,onZoomOut:B,onFitToView:te,canvasRef:t,onCanvasModified:P})]})});export{Ll as CanvasPanel,Ll as default};
|
|
441
|
-
//# sourceMappingURL=CanvasPanel-
|
|
441
|
+
//# sourceMappingURL=CanvasPanel-Cogtmutb.js.map
|