@nocios/crudify-ui 1.3.2 → 1.3.6

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/index.mjs CHANGED
@@ -2027,19 +2027,631 @@ var UserProfileDisplay = ({
2027
2027
  };
2028
2028
  var UserProfileDisplay_default = UserProfileDisplay;
2029
2029
 
2030
+ // src/components/PublicPolicies/Policies.tsx
2031
+ import { useRef as useRef4 } from "react";
2032
+ import { useTranslation as useTranslation4 } from "react-i18next";
2033
+ import {
2034
+ Box as Box10,
2035
+ Typography as Typography10,
2036
+ Button as Button7,
2037
+ Stack as Stack3,
2038
+ Alert as Alert7,
2039
+ Divider as Divider3
2040
+ } from "@mui/material";
2041
+ import { Add } from "@mui/icons-material";
2042
+
2043
+ // src/components/PublicPolicies/PolicyItem/PolicyItem.tsx
2044
+ import { forwardRef } from "react";
2045
+ import { useTranslation as useTranslation3 } from "react-i18next";
2046
+ import {
2047
+ Box as Box9,
2048
+ FormControl,
2049
+ InputLabel,
2050
+ Select,
2051
+ MenuItem,
2052
+ IconButton as IconButton2,
2053
+ Typography as Typography9,
2054
+ FormHelperText as FormHelperText2,
2055
+ Stack as Stack2,
2056
+ Paper,
2057
+ Divider as Divider2,
2058
+ Button as Button6
2059
+ } from "@mui/material";
2060
+ import { Delete, SelectAll as SelectAll2, ClearAll as ClearAll2 } from "@mui/icons-material";
2061
+
2062
+ // src/components/PublicPolicies/FieldSelector/FieldSelector.tsx
2063
+ import { useState as useState8, useEffect as useEffect8, useRef as useRef3 } from "react";
2064
+ import { useTranslation as useTranslation2 } from "react-i18next";
2065
+ import {
2066
+ Box as Box8,
2067
+ Typography as Typography8,
2068
+ Button as Button5,
2069
+ Stack,
2070
+ FormHelperText,
2071
+ ToggleButton,
2072
+ ToggleButtonGroup
2073
+ } from "@mui/material";
2074
+ import {
2075
+ CheckCircle,
2076
+ Cancel,
2077
+ SelectAll,
2078
+ ClearAll
2079
+ } from "@mui/icons-material";
2080
+ import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
2081
+ var FieldSelector = ({
2082
+ value,
2083
+ onChange,
2084
+ availableFields,
2085
+ error,
2086
+ disabled = false
2087
+ }) => {
2088
+ const { t } = useTranslation2();
2089
+ const [mode, setMode] = useState8("custom");
2090
+ const isUpdatingRef = useRef3(false);
2091
+ useEffect8(() => {
2092
+ const current = value || { allow: [], owner_allow: [], deny: [] };
2093
+ const all = new Set(availableFields);
2094
+ const allow = (current.allow || []).filter((f) => all.has(f));
2095
+ const owner = (current.owner_allow || []).filter((f) => all.has(f));
2096
+ const deny = (current.deny || []).filter((f) => all.has(f));
2097
+ availableFields.forEach((f) => {
2098
+ if (!allow.includes(f) && !owner.includes(f) && !deny.includes(f)) deny.push(f);
2099
+ });
2100
+ const normalized = { allow, owner_allow: owner, deny };
2101
+ if (JSON.stringify(normalized) !== JSON.stringify(current)) {
2102
+ onChange(normalized);
2103
+ }
2104
+ if (allow.length === availableFields.length) setMode("all");
2105
+ else if (deny.length === availableFields.length) setMode("none");
2106
+ else setMode("custom");
2107
+ }, [availableFields, value]);
2108
+ const setAllAllow = () => {
2109
+ isUpdatingRef.current = true;
2110
+ onChange({ allow: [...availableFields], owner_allow: [], deny: [] });
2111
+ setMode("all");
2112
+ setTimeout(() => {
2113
+ isUpdatingRef.current = false;
2114
+ }, 0);
2115
+ };
2116
+ const setAllDeny = () => {
2117
+ isUpdatingRef.current = true;
2118
+ onChange({ allow: [], owner_allow: [], deny: [...availableFields] });
2119
+ setMode("none");
2120
+ setTimeout(() => {
2121
+ isUpdatingRef.current = false;
2122
+ }, 0);
2123
+ };
2124
+ const getFieldState = (fieldName) => {
2125
+ if (value?.allow?.includes(fieldName)) return "allow";
2126
+ if (value?.owner_allow?.includes(fieldName)) return "owner_allow";
2127
+ return "deny";
2128
+ };
2129
+ const setFieldState = (fieldName, state) => {
2130
+ isUpdatingRef.current = true;
2131
+ const allow = new Set(value?.allow || []);
2132
+ const owner = new Set(value?.owner_allow || []);
2133
+ const deny = new Set(value?.deny || []);
2134
+ allow.delete(fieldName);
2135
+ owner.delete(fieldName);
2136
+ deny.delete(fieldName);
2137
+ if (state === "allow") allow.add(fieldName);
2138
+ if (state === "owner_allow") owner.add(fieldName);
2139
+ if (state === "deny") deny.add(fieldName);
2140
+ onChange({ allow: Array.from(allow), owner_allow: Array.from(owner), deny: Array.from(deny) });
2141
+ setMode("custom");
2142
+ setTimeout(() => {
2143
+ isUpdatingRef.current = false;
2144
+ }, 0);
2145
+ };
2146
+ if (availableFields.length === 0) {
2147
+ return /* @__PURE__ */ jsxs8(Box8, { children: [
2148
+ /* @__PURE__ */ jsx11(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 1 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
2149
+ /* @__PURE__ */ jsx11(Typography8, { variant: "body2", color: "text.secondary", sx: { fontStyle: "italic" }, children: t("modules.form.publicPolicies.fields.conditions.noFieldsAvailable") }),
2150
+ error && /* @__PURE__ */ jsx11(FormHelperText, { error: true, sx: { mt: 1 }, children: error })
2151
+ ] });
2152
+ }
2153
+ return /* @__PURE__ */ jsxs8(Box8, { children: [
2154
+ /* @__PURE__ */ jsx11(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
2155
+ /* @__PURE__ */ jsxs8(Stack, { direction: "row", spacing: 1, sx: { mb: 3 }, children: [
2156
+ /* @__PURE__ */ jsx11(
2157
+ Button5,
2158
+ {
2159
+ variant: mode === "all" ? "contained" : "outlined",
2160
+ startIcon: /* @__PURE__ */ jsx11(SelectAll, {}),
2161
+ onClick: setAllAllow,
2162
+ disabled,
2163
+ size: "small",
2164
+ sx: {
2165
+ minWidth: 120,
2166
+ ...mode === "all" && {
2167
+ backgroundColor: "#16a34a",
2168
+ "&:hover": { backgroundColor: "#15803d" }
2169
+ }
2170
+ },
2171
+ children: t("modules.form.publicPolicies.fields.conditions.allFields")
2172
+ }
2173
+ ),
2174
+ /* @__PURE__ */ jsx11(
2175
+ Button5,
2176
+ {
2177
+ variant: mode === "none" ? "contained" : "outlined",
2178
+ startIcon: /* @__PURE__ */ jsx11(ClearAll, {}),
2179
+ onClick: setAllDeny,
2180
+ disabled,
2181
+ size: "small",
2182
+ sx: {
2183
+ minWidth: 120,
2184
+ ...mode === "none" && {
2185
+ backgroundColor: "#cf222e",
2186
+ "&:hover": { backgroundColor: "#bc1f2c" }
2187
+ }
2188
+ },
2189
+ children: t("modules.form.publicPolicies.fields.conditions.noFields")
2190
+ }
2191
+ )
2192
+ ] }),
2193
+ /* @__PURE__ */ jsxs8(Box8, { sx: { p: 2, border: "1px solid #d1d9e0", borderRadius: 1, backgroundColor: "#f6f8fa" }, children: [
2194
+ /* @__PURE__ */ jsx11(Typography8, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.help") }),
2195
+ /* @__PURE__ */ jsx11(Stack, { spacing: 1, children: availableFields.map((fieldName) => {
2196
+ const fieldState = getFieldState(fieldName);
2197
+ return /* @__PURE__ */ jsxs8(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
2198
+ /* @__PURE__ */ jsx11(Typography8, { variant: "body2", sx: { minWidth: 100, fontFamily: "monospace" }, children: fieldName }),
2199
+ /* @__PURE__ */ jsxs8(ToggleButtonGroup, { value: fieldState, exclusive: true, size: "small", children: [
2200
+ /* @__PURE__ */ jsxs8(
2201
+ ToggleButton,
2202
+ {
2203
+ value: "allow",
2204
+ onClick: () => setFieldState(fieldName, "allow"),
2205
+ disabled,
2206
+ sx: {
2207
+ px: 2,
2208
+ color: fieldState === "allow" ? "#ffffff" : "#6b7280",
2209
+ backgroundColor: fieldState === "allow" ? "#16a34a" : "#f3f4f6",
2210
+ borderColor: fieldState === "allow" ? "#16a34a" : "#d1d5db",
2211
+ "&:hover": {
2212
+ backgroundColor: fieldState === "allow" ? "#15803d" : "#e5e7eb",
2213
+ borderColor: fieldState === "allow" ? "#15803d" : "#9ca3af"
2214
+ },
2215
+ "&.Mui-selected": {
2216
+ backgroundColor: "#16a34a",
2217
+ color: "#ffffff",
2218
+ "&:hover": {
2219
+ backgroundColor: "#15803d"
2220
+ }
2221
+ }
2222
+ },
2223
+ children: [
2224
+ /* @__PURE__ */ jsx11(CheckCircle, { sx: { fontSize: 16, mr: 0.5 } }),
2225
+ t("modules.form.publicPolicies.fields.conditions.states.allow")
2226
+ ]
2227
+ }
2228
+ ),
2229
+ /* @__PURE__ */ jsx11(
2230
+ ToggleButton,
2231
+ {
2232
+ value: "owner_allow",
2233
+ onClick: () => setFieldState(fieldName, "owner_allow"),
2234
+ disabled,
2235
+ sx: {
2236
+ px: 2,
2237
+ color: fieldState === "owner_allow" ? "#ffffff" : "#6b7280",
2238
+ backgroundColor: fieldState === "owner_allow" ? "#0ea5e9" : "#f3f4f6",
2239
+ borderColor: fieldState === "owner_allow" ? "#0ea5e9" : "#d1d5db",
2240
+ "&:hover": {
2241
+ backgroundColor: fieldState === "owner_allow" ? "#0284c7" : "#e5e7eb",
2242
+ borderColor: fieldState === "owner_allow" ? "#0284c7" : "#9ca3af"
2243
+ },
2244
+ "&.Mui-selected": {
2245
+ backgroundColor: "#0ea5e9",
2246
+ color: "#ffffff",
2247
+ "&:hover": {
2248
+ backgroundColor: "#0284c7"
2249
+ }
2250
+ }
2251
+ },
2252
+ children: t("modules.form.publicPolicies.fields.conditions.states.ownerAllow")
2253
+ }
2254
+ ),
2255
+ /* @__PURE__ */ jsxs8(
2256
+ ToggleButton,
2257
+ {
2258
+ value: "deny",
2259
+ onClick: () => setFieldState(fieldName, "deny"),
2260
+ disabled,
2261
+ sx: {
2262
+ px: 2,
2263
+ color: fieldState === "deny" ? "#ffffff" : "#6b7280",
2264
+ backgroundColor: fieldState === "deny" ? "#dc2626" : "#f3f4f6",
2265
+ borderColor: fieldState === "deny" ? "#dc2626" : "#d1d5db",
2266
+ "&:hover": {
2267
+ backgroundColor: fieldState === "deny" ? "#b91c1c" : "#e5e7eb",
2268
+ borderColor: fieldState === "deny" ? "#b91c1c" : "#9ca3af"
2269
+ },
2270
+ "&.Mui-selected": {
2271
+ backgroundColor: "#dc2626",
2272
+ color: "#ffffff",
2273
+ "&:hover": {
2274
+ backgroundColor: "#b91c1c"
2275
+ }
2276
+ }
2277
+ },
2278
+ children: [
2279
+ /* @__PURE__ */ jsx11(Cancel, { sx: { fontSize: 16, mr: 0.5 } }),
2280
+ t("modules.form.publicPolicies.fields.conditions.states.deny")
2281
+ ]
2282
+ }
2283
+ )
2284
+ ] })
2285
+ ] }, fieldName);
2286
+ }) })
2287
+ ] }),
2288
+ error && /* @__PURE__ */ jsx11(FormHelperText, { error: true, sx: { mt: 1 }, children: error })
2289
+ ] });
2290
+ };
2291
+ var FieldSelector_default = FieldSelector;
2292
+
2293
+ // src/components/PublicPolicies/constants.ts
2294
+ var POLICY_ACTIONS = ["create", "read", "update", "delete"];
2295
+ var PREFERRED_POLICY_ORDER = [
2296
+ "create",
2297
+ "read",
2298
+ "update",
2299
+ "delete"
2300
+ ];
2301
+
2302
+ // src/components/PublicPolicies/PolicyItem/PolicyItem.tsx
2303
+ import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
2304
+ var PolicyItem = forwardRef(({
2305
+ policy,
2306
+ onChange,
2307
+ onRemove,
2308
+ availableFields,
2309
+ isSubmitting = false,
2310
+ usedActions,
2311
+ error
2312
+ }, ref) => {
2313
+ const { t } = useTranslation3();
2314
+ const takenActions = new Set(Array.from(usedActions || []));
2315
+ takenActions.delete(policy.action);
2316
+ const actionOptions = POLICY_ACTIONS.map((a) => ({
2317
+ value: a,
2318
+ label: t(`modules.form.publicPolicies.fields.action.options.${a}`)
2319
+ }));
2320
+ return /* @__PURE__ */ jsxs9(
2321
+ Paper,
2322
+ {
2323
+ ref,
2324
+ sx: {
2325
+ p: 3,
2326
+ border: "1px solid #d1d9e0",
2327
+ borderRadius: 2,
2328
+ position: "relative",
2329
+ backgroundColor: "#ffffff"
2330
+ },
2331
+ children: [
2332
+ /* @__PURE__ */ jsxs9(Box9, { sx: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", mb: 3 }, children: [
2333
+ /* @__PURE__ */ jsx12(
2334
+ Typography9,
2335
+ {
2336
+ variant: "subtitle1",
2337
+ sx: {
2338
+ fontWeight: 600,
2339
+ color: "#111418",
2340
+ fontSize: "1rem"
2341
+ },
2342
+ children: t("modules.form.publicPolicies.policyTitle")
2343
+ }
2344
+ ),
2345
+ /* @__PURE__ */ jsx12(
2346
+ IconButton2,
2347
+ {
2348
+ onClick: onRemove,
2349
+ size: "small",
2350
+ disabled: isSubmitting,
2351
+ "aria-label": t("modules.form.publicPolicies.removePolicy"),
2352
+ sx: {
2353
+ color: "#656d76",
2354
+ "&:hover": {
2355
+ color: "#cf222e",
2356
+ backgroundColor: "rgba(207, 34, 46, 0.1)"
2357
+ }
2358
+ },
2359
+ children: /* @__PURE__ */ jsx12(Delete, {})
2360
+ }
2361
+ )
2362
+ ] }),
2363
+ /* @__PURE__ */ jsxs9(Stack2, { spacing: 3, children: [
2364
+ /* @__PURE__ */ jsx12(Stack2, { direction: { xs: "column", md: "row" }, spacing: 2, children: /* @__PURE__ */ jsx12(Box9, { sx: { flex: 1, minWidth: 200 }, children: /* @__PURE__ */ jsxs9(FormControl, { fullWidth: true, children: [
2365
+ /* @__PURE__ */ jsx12(InputLabel, { children: t("modules.form.publicPolicies.fields.action.label") }),
2366
+ /* @__PURE__ */ jsx12(
2367
+ Select,
2368
+ {
2369
+ value: policy.action,
2370
+ label: t("modules.form.publicPolicies.fields.action.label"),
2371
+ disabled: isSubmitting,
2372
+ onChange: (e) => {
2373
+ const newAction = e.target.value;
2374
+ const next = { ...policy, action: newAction };
2375
+ if (newAction === "delete") {
2376
+ next.permission = "deny";
2377
+ delete next.fields;
2378
+ } else {
2379
+ next.fields = { allow: [], owner_allow: [], deny: availableFields };
2380
+ delete next.permission;
2381
+ }
2382
+ onChange(next);
2383
+ },
2384
+ sx: {
2385
+ backgroundColor: "#ffffff",
2386
+ "&:hover .MuiOutlinedInput-notchedOutline": {
2387
+ borderColor: "#8c959f"
2388
+ },
2389
+ "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
2390
+ borderColor: "#0969da",
2391
+ borderWidth: 2
2392
+ }
2393
+ },
2394
+ children: actionOptions.map((option) => {
2395
+ const disabledOption = takenActions.has(option.value);
2396
+ return /* @__PURE__ */ jsx12(MenuItem, { value: option.value, disabled: disabledOption, children: option.label }, option.value);
2397
+ })
2398
+ }
2399
+ ),
2400
+ error && /* @__PURE__ */ jsx12(FormHelperText2, { error: true, children: error })
2401
+ ] }) }) }),
2402
+ policy.action === "delete" ? /* @__PURE__ */ jsxs9(Box9, { children: [
2403
+ /* @__PURE__ */ jsx12(Typography9, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: t("modules.form.publicPolicies.fields.conditions.label") }),
2404
+ /* @__PURE__ */ jsxs9(Stack2, { direction: "row", spacing: 1, sx: { mb: 3 }, children: [
2405
+ /* @__PURE__ */ jsx12(
2406
+ Button6,
2407
+ {
2408
+ variant: policy.permission === "*" ? "contained" : "outlined",
2409
+ startIcon: /* @__PURE__ */ jsx12(SelectAll2, {}),
2410
+ onClick: () => onChange({ ...policy, permission: "*" }),
2411
+ disabled: isSubmitting,
2412
+ size: "small",
2413
+ sx: {
2414
+ minWidth: 140,
2415
+ whiteSpace: "nowrap",
2416
+ ...policy.permission === "*" && {
2417
+ backgroundColor: "#16a34a",
2418
+ "&:hover": { backgroundColor: "#15803d" }
2419
+ }
2420
+ },
2421
+ children: t("modules.form.publicPolicies.fields.conditions.allFields")
2422
+ }
2423
+ ),
2424
+ /* @__PURE__ */ jsx12(
2425
+ Button6,
2426
+ {
2427
+ variant: policy.permission === "owner" ? "contained" : "outlined",
2428
+ onClick: () => onChange({ ...policy, permission: "owner" }),
2429
+ disabled: isSubmitting,
2430
+ size: "small",
2431
+ sx: {
2432
+ minWidth: 140,
2433
+ whiteSpace: "nowrap",
2434
+ ...policy.permission === "owner" && {
2435
+ backgroundColor: "#0ea5e9",
2436
+ "&:hover": { backgroundColor: "#0284c7" }
2437
+ }
2438
+ },
2439
+ children: t("modules.form.publicPolicies.fields.conditions.states.ownerAllow")
2440
+ }
2441
+ ),
2442
+ /* @__PURE__ */ jsx12(
2443
+ Button6,
2444
+ {
2445
+ variant: policy.permission === "deny" ? "contained" : "outlined",
2446
+ startIcon: /* @__PURE__ */ jsx12(ClearAll2, {}),
2447
+ onClick: () => onChange({ ...policy, permission: "deny" }),
2448
+ disabled: isSubmitting,
2449
+ size: "small",
2450
+ sx: {
2451
+ minWidth: 140,
2452
+ whiteSpace: "nowrap",
2453
+ ...policy.permission === "deny" && {
2454
+ backgroundColor: "#cf222e",
2455
+ "&:hover": { backgroundColor: "#bc1f2c" }
2456
+ }
2457
+ },
2458
+ children: t("modules.form.publicPolicies.fields.conditions.noFields")
2459
+ }
2460
+ )
2461
+ ] })
2462
+ ] }) : /* @__PURE__ */ jsx12(
2463
+ FieldSelector_default,
2464
+ {
2465
+ value: policy.fields || { allow: [], owner_allow: [], deny: [] },
2466
+ onChange: (nextFields) => onChange({ ...policy, fields: nextFields }),
2467
+ availableFields,
2468
+ disabled: isSubmitting
2469
+ }
2470
+ ),
2471
+ /* @__PURE__ */ jsx12(Paper, { variant: "outlined", sx: { p: 2, backgroundColor: "#f9fafb" }, children: policy.action === "delete" ? /* @__PURE__ */ jsxs9(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
2472
+ /* @__PURE__ */ jsxs9(Box9, { component: "span", sx: {
2473
+ color: policy.permission === "*" ? "#16a34a" : policy.permission === "owner" ? "#0ea5e9" : "#dc2626"
2474
+ }, children: [
2475
+ t("modules.form.publicPolicies.fields.conditions.states.allow"),
2476
+ ":"
2477
+ ] }),
2478
+ " ",
2479
+ policy.permission || "-"
2480
+ ] }) : /* @__PURE__ */ jsxs9(Stack2, { spacing: 0.5, divider: /* @__PURE__ */ jsx12(Divider2, { sx: { borderColor: "#e5e7eb" } }), children: [
2481
+ /* @__PURE__ */ jsxs9(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
2482
+ /* @__PURE__ */ jsxs9(Box9, { component: "span", sx: { color: "#16a34a" }, children: [
2483
+ t("modules.form.publicPolicies.fields.conditions.states.allow"),
2484
+ ":"
2485
+ ] }),
2486
+ " ",
2487
+ (policy?.fields?.allow || []).join(", ") || "-"
2488
+ ] }),
2489
+ /* @__PURE__ */ jsxs9(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
2490
+ /* @__PURE__ */ jsxs9(Box9, { component: "span", sx: { color: "#0ea5e9" }, children: [
2491
+ t("modules.form.publicPolicies.fields.conditions.states.ownerAllow"),
2492
+ ":"
2493
+ ] }),
2494
+ " ",
2495
+ (policy?.fields?.owner_allow || []).join(", ") || "-"
2496
+ ] }),
2497
+ /* @__PURE__ */ jsxs9(Typography9, { variant: "body2", sx: { fontFamily: "monospace", color: "text.secondary" }, children: [
2498
+ /* @__PURE__ */ jsxs9(Box9, { component: "span", sx: { color: "#dc2626" }, children: [
2499
+ t("modules.form.publicPolicies.fields.conditions.states.deny"),
2500
+ ":"
2501
+ ] }),
2502
+ " ",
2503
+ (policy?.fields?.deny || []).join(", ") || "-"
2504
+ ] })
2505
+ ] }) })
2506
+ ] })
2507
+ ]
2508
+ }
2509
+ );
2510
+ });
2511
+ var PolicyItem_default = PolicyItem;
2512
+
2513
+ // src/components/PublicPolicies/Policies.tsx
2514
+ import { Fragment as Fragment7, jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
2515
+ var generateId = () => {
2516
+ const c = globalThis?.crypto;
2517
+ if (c && typeof c.randomUUID === "function") return c.randomUUID();
2518
+ return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
2519
+ };
2520
+ var Policies = ({
2521
+ policies,
2522
+ onChange,
2523
+ availableFields,
2524
+ errors,
2525
+ isSubmitting = false
2526
+ }) => {
2527
+ const { t } = useTranslation4();
2528
+ const policyRefs = useRef4({});
2529
+ const takenActions = new Set((policies || []).map((p) => p.action).filter(Boolean));
2530
+ const remainingActions = PREFERRED_POLICY_ORDER.filter((a) => !takenActions.has(a));
2531
+ const canAddPolicy = remainingActions.length > 0;
2532
+ const addPolicy = () => {
2533
+ const defaultAction = remainingActions[0] || "create";
2534
+ const newPolicy = {
2535
+ id: generateId(),
2536
+ action: defaultAction
2537
+ };
2538
+ if (defaultAction === "delete") {
2539
+ newPolicy.permission = "deny";
2540
+ } else {
2541
+ newPolicy.fields = {
2542
+ allow: [],
2543
+ owner_allow: [],
2544
+ deny: availableFields
2545
+ };
2546
+ }
2547
+ const next = [...policies || [], newPolicy];
2548
+ onChange(next);
2549
+ setTimeout(() => {
2550
+ const newIndex = next.length - 1;
2551
+ const el = policyRefs.current[newIndex];
2552
+ if (el) {
2553
+ el.scrollIntoView({ behavior: "smooth", block: "center" });
2554
+ }
2555
+ }, 100);
2556
+ };
2557
+ const removePolicy = (index) => {
2558
+ const next = [...policies];
2559
+ next.splice(index, 1);
2560
+ onChange(next);
2561
+ };
2562
+ const arrayError = (() => {
2563
+ if (!errors) return null;
2564
+ if (typeof errors === "string") return errors;
2565
+ const msg = errors._error;
2566
+ return typeof msg === "string" ? msg : null;
2567
+ })();
2568
+ const usedActions = new Set((policies || []).map((p) => p.action));
2569
+ return /* @__PURE__ */ jsxs10(Fragment7, { children: [
2570
+ /* @__PURE__ */ jsx13(Divider3, { sx: { borderColor: "#e0e4e7" } }),
2571
+ /* @__PURE__ */ jsxs10(Box10, { children: [
2572
+ /* @__PURE__ */ jsx13(Box10, { display: "flex", justifyContent: "space-between", alignItems: "center", mb: 3, children: /* @__PURE__ */ jsxs10(Box10, { children: [
2573
+ /* @__PURE__ */ jsx13(
2574
+ Typography10,
2575
+ {
2576
+ variant: "h6",
2577
+ sx: {
2578
+ fontWeight: 600,
2579
+ color: "#111418",
2580
+ mb: 1
2581
+ },
2582
+ children: t("modules.form.publicPolicies.title")
2583
+ }
2584
+ ),
2585
+ /* @__PURE__ */ jsx13(
2586
+ Typography10,
2587
+ {
2588
+ variant: "body2",
2589
+ color: "text.secondary",
2590
+ sx: { fontSize: "0.875rem" },
2591
+ children: t("modules.form.publicPolicies.description")
2592
+ }
2593
+ )
2594
+ ] }) }),
2595
+ arrayError && /* @__PURE__ */ jsx13(Alert7, { severity: "error", sx: { mb: 3 }, children: arrayError }),
2596
+ /* @__PURE__ */ jsxs10(Stack3, { spacing: 3, children: [
2597
+ (policies || []).length === 0 ? /* @__PURE__ */ jsx13(Alert7, { severity: "info", children: t("modules.form.publicPolicies.noPolicies") }) : policies.map((policy, index) => /* @__PURE__ */ jsx13(
2598
+ PolicyItem_default,
2599
+ {
2600
+ ref: (el) => {
2601
+ policyRefs.current[index] = el;
2602
+ },
2603
+ policy,
2604
+ onChange: (nextPolicy) => {
2605
+ const next = [...policies];
2606
+ next[index] = nextPolicy;
2607
+ onChange(next);
2608
+ },
2609
+ onRemove: () => removePolicy(index),
2610
+ availableFields,
2611
+ isSubmitting,
2612
+ usedActions,
2613
+ error: typeof errors === "object" && errors && policy.id in errors ? errors[policy.id] : void 0
2614
+ },
2615
+ policy.id
2616
+ )),
2617
+ canAddPolicy && /* @__PURE__ */ jsx13(Box10, { children: /* @__PURE__ */ jsx13(
2618
+ Button7,
2619
+ {
2620
+ type: "button",
2621
+ variant: "outlined",
2622
+ startIcon: /* @__PURE__ */ jsx13(Add, {}),
2623
+ onClick: addPolicy,
2624
+ disabled: isSubmitting,
2625
+ sx: {
2626
+ borderColor: "#d0d7de",
2627
+ color: "#656d76",
2628
+ "&:hover": {
2629
+ borderColor: "#8c959f",
2630
+ backgroundColor: "transparent"
2631
+ }
2632
+ },
2633
+ children: t("modules.form.publicPolicies.addPolicy")
2634
+ }
2635
+ ) })
2636
+ ] })
2637
+ ] })
2638
+ ] });
2639
+ };
2640
+ var Policies_default = Policies;
2641
+
2030
2642
  // src/hooks/useCrudifyUser.ts
2031
- import { useState as useState8, useEffect as useEffect8, useCallback as useCallback2, useRef as useRef3 } from "react";
2643
+ import { useState as useState9, useEffect as useEffect9, useCallback as useCallback2, useRef as useRef5 } from "react";
2032
2644
  import crudify3 from "@nocios/crudify-browser";
2033
2645
  var useCrudifyUser = (options = {}) => {
2034
2646
  const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
2035
2647
  const { isAuthenticated, isInitialized, user: jwtUser, token } = useCrudifyDataContext();
2036
- const [userData, setUserData] = useState8(null);
2037
- const [loading, setLoading] = useState8(false);
2038
- const [error, setError] = useState8(null);
2039
- const abortControllerRef = useRef3(null);
2040
- const mountedRef = useRef3(true);
2041
- const requestIdRef = useRef3(0);
2042
- const retryCountRef = useRef3(0);
2648
+ const [userData, setUserData] = useState9(null);
2649
+ const [loading, setLoading] = useState9(false);
2650
+ const [error, setError] = useState9(null);
2651
+ const abortControllerRef = useRef5(null);
2652
+ const mountedRef = useRef5(true);
2653
+ const requestIdRef = useRef5(0);
2654
+ const retryCountRef = useRef5(0);
2043
2655
  const getUserEmailFromJWT = useCallback2(() => {
2044
2656
  if (!jwtUser) return null;
2045
2657
  return jwtUser.email || jwtUser["cognito:username"] || null;
@@ -2182,14 +2794,14 @@ var useCrudifyUser = (options = {}) => {
2182
2794
  }
2183
2795
  }
2184
2796
  }, [isInitialized, getUserEmailFromJWT, retryOnError, maxRetries]);
2185
- useEffect8(() => {
2797
+ useEffect9(() => {
2186
2798
  if (autoFetch && isAuthenticated && isInitialized) {
2187
2799
  refreshProfile();
2188
2800
  } else if (!isAuthenticated) {
2189
2801
  clearProfile();
2190
2802
  }
2191
2803
  }, [autoFetch, isAuthenticated, isInitialized, refreshProfile, clearProfile]);
2192
- useEffect8(() => {
2804
+ useEffect9(() => {
2193
2805
  mountedRef.current = true;
2194
2806
  return () => {
2195
2807
  mountedRef.current = false;
@@ -2959,9 +3571,9 @@ var SessionManager = class _SessionManager {
2959
3571
  };
2960
3572
 
2961
3573
  // src/hooks/useSession.ts
2962
- import { useState as useState9, useEffect as useEffect9, useCallback as useCallback5 } from "react";
3574
+ import { useState as useState10, useEffect as useEffect10, useCallback as useCallback5 } from "react";
2963
3575
  function useSession(options = {}) {
2964
- const [state, setState] = useState9({
3576
+ const [state, setState] = useState10({
2965
3577
  isAuthenticated: false,
2966
3578
  isLoading: true,
2967
3579
  isInitialized: false,
@@ -3133,7 +3745,7 @@ function useSession(options = {}) {
3133
3745
  const getTokenInfo = useCallback5(() => {
3134
3746
  return sessionManager.getTokenInfo();
3135
3747
  }, [sessionManager]);
3136
- useEffect9(() => {
3748
+ useEffect10(() => {
3137
3749
  initialize();
3138
3750
  }, [initialize]);
3139
3751
  return {
@@ -3155,7 +3767,7 @@ function useSession(options = {}) {
3155
3767
 
3156
3768
  // src/providers/SessionProvider.tsx
3157
3769
  import { createContext as createContext4, useContext as useContext4, useMemo as useMemo3 } from "react";
3158
- import { Fragment as Fragment7, jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
3770
+ import { Fragment as Fragment8, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
3159
3771
  var SessionContext = createContext4(void 0);
3160
3772
  function SessionProvider({ children, options = {} }) {
3161
3773
  const sessionHook = useSession(options);
@@ -3187,7 +3799,7 @@ function SessionProvider({ children, options = {} }) {
3187
3799
  ...sessionHook,
3188
3800
  sessionData
3189
3801
  };
3190
- return /* @__PURE__ */ jsx11(SessionContext.Provider, { value: contextValue, children });
3802
+ return /* @__PURE__ */ jsx14(SessionContext.Provider, { value: contextValue, children });
3191
3803
  }
3192
3804
  function useSessionContext() {
3193
3805
  const context = useContext4(SessionContext);
@@ -3198,28 +3810,28 @@ function useSessionContext() {
3198
3810
  }
3199
3811
  function ProtectedRoute({
3200
3812
  children,
3201
- fallback = /* @__PURE__ */ jsx11("div", { children: "Please log in to access this content" }),
3813
+ fallback = /* @__PURE__ */ jsx14("div", { children: "Please log in to access this content" }),
3202
3814
  redirectTo
3203
3815
  }) {
3204
3816
  const { isAuthenticated, isLoading, isInitialized } = useSessionContext();
3205
3817
  if (!isInitialized || isLoading) {
3206
- return /* @__PURE__ */ jsx11("div", { children: "Loading..." });
3818
+ return /* @__PURE__ */ jsx14("div", { children: "Loading..." });
3207
3819
  }
3208
3820
  if (!isAuthenticated) {
3209
3821
  if (redirectTo) {
3210
3822
  redirectTo();
3211
3823
  return null;
3212
3824
  }
3213
- return /* @__PURE__ */ jsx11(Fragment7, { children: fallback });
3825
+ return /* @__PURE__ */ jsx14(Fragment8, { children: fallback });
3214
3826
  }
3215
- return /* @__PURE__ */ jsx11(Fragment7, { children });
3827
+ return /* @__PURE__ */ jsx14(Fragment8, { children });
3216
3828
  }
3217
3829
  function SessionDebugInfo() {
3218
3830
  const session = useSessionContext();
3219
3831
  if (!session.isInitialized) {
3220
- return /* @__PURE__ */ jsx11("div", { children: "Session not initialized" });
3832
+ return /* @__PURE__ */ jsx14("div", { children: "Session not initialized" });
3221
3833
  }
3222
- return /* @__PURE__ */ jsxs8("div", { style: {
3834
+ return /* @__PURE__ */ jsxs11("div", { style: {
3223
3835
  padding: "10px",
3224
3836
  margin: "10px",
3225
3837
  border: "1px solid #ccc",
@@ -3227,49 +3839,49 @@ function SessionDebugInfo() {
3227
3839
  fontSize: "12px",
3228
3840
  fontFamily: "monospace"
3229
3841
  }, children: [
3230
- /* @__PURE__ */ jsx11("h4", { children: "Session Debug Info" }),
3231
- /* @__PURE__ */ jsxs8("div", { children: [
3232
- /* @__PURE__ */ jsx11("strong", { children: "Authenticated:" }),
3842
+ /* @__PURE__ */ jsx14("h4", { children: "Session Debug Info" }),
3843
+ /* @__PURE__ */ jsxs11("div", { children: [
3844
+ /* @__PURE__ */ jsx14("strong", { children: "Authenticated:" }),
3233
3845
  " ",
3234
3846
  session.isAuthenticated ? "Yes" : "No"
3235
3847
  ] }),
3236
- /* @__PURE__ */ jsxs8("div", { children: [
3237
- /* @__PURE__ */ jsx11("strong", { children: "Loading:" }),
3848
+ /* @__PURE__ */ jsxs11("div", { children: [
3849
+ /* @__PURE__ */ jsx14("strong", { children: "Loading:" }),
3238
3850
  " ",
3239
3851
  session.isLoading ? "Yes" : "No"
3240
3852
  ] }),
3241
- /* @__PURE__ */ jsxs8("div", { children: [
3242
- /* @__PURE__ */ jsx11("strong", { children: "Error:" }),
3853
+ /* @__PURE__ */ jsxs11("div", { children: [
3854
+ /* @__PURE__ */ jsx14("strong", { children: "Error:" }),
3243
3855
  " ",
3244
3856
  session.error || "None"
3245
3857
  ] }),
3246
- session.tokens && /* @__PURE__ */ jsxs8(Fragment7, { children: [
3247
- /* @__PURE__ */ jsxs8("div", { children: [
3248
- /* @__PURE__ */ jsx11("strong", { children: "Access Token:" }),
3858
+ session.tokens && /* @__PURE__ */ jsxs11(Fragment8, { children: [
3859
+ /* @__PURE__ */ jsxs11("div", { children: [
3860
+ /* @__PURE__ */ jsx14("strong", { children: "Access Token:" }),
3249
3861
  " ",
3250
3862
  session.tokens.accessToken.substring(0, 20),
3251
3863
  "..."
3252
3864
  ] }),
3253
- /* @__PURE__ */ jsxs8("div", { children: [
3254
- /* @__PURE__ */ jsx11("strong", { children: "Refresh Token:" }),
3865
+ /* @__PURE__ */ jsxs11("div", { children: [
3866
+ /* @__PURE__ */ jsx14("strong", { children: "Refresh Token:" }),
3255
3867
  " ",
3256
3868
  session.tokens.refreshToken.substring(0, 20),
3257
3869
  "..."
3258
3870
  ] }),
3259
- /* @__PURE__ */ jsxs8("div", { children: [
3260
- /* @__PURE__ */ jsx11("strong", { children: "Access Expires In:" }),
3871
+ /* @__PURE__ */ jsxs11("div", { children: [
3872
+ /* @__PURE__ */ jsx14("strong", { children: "Access Expires In:" }),
3261
3873
  " ",
3262
3874
  Math.round(session.expiresIn / 1e3 / 60),
3263
3875
  " minutes"
3264
3876
  ] }),
3265
- /* @__PURE__ */ jsxs8("div", { children: [
3266
- /* @__PURE__ */ jsx11("strong", { children: "Refresh Expires In:" }),
3877
+ /* @__PURE__ */ jsxs11("div", { children: [
3878
+ /* @__PURE__ */ jsx14("strong", { children: "Refresh Expires In:" }),
3267
3879
  " ",
3268
3880
  Math.round(session.refreshExpiresIn / 1e3 / 60 / 60),
3269
3881
  " hours"
3270
3882
  ] }),
3271
- /* @__PURE__ */ jsxs8("div", { children: [
3272
- /* @__PURE__ */ jsx11("strong", { children: "Expiring Soon:" }),
3883
+ /* @__PURE__ */ jsxs11("div", { children: [
3884
+ /* @__PURE__ */ jsx14("strong", { children: "Expiring Soon:" }),
3273
3885
  " ",
3274
3886
  session.isExpiringSoon ? "Yes" : "No"
3275
3887
  ] })
@@ -3278,13 +3890,13 @@ function SessionDebugInfo() {
3278
3890
  }
3279
3891
 
3280
3892
  // src/components/LoginComponent.tsx
3281
- import { useState as useState10 } from "react";
3282
- import { Button as Button5, TextField as TextField5, Box as Box8, Alert as Alert7, Typography as Typography8, CircularProgress as CircularProgress7 } from "@mui/material";
3283
- import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
3893
+ import { useState as useState11 } from "react";
3894
+ import { Button as Button8, TextField as TextField5, Box as Box11, Alert as Alert8, Typography as Typography11, CircularProgress as CircularProgress7 } from "@mui/material";
3895
+ import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
3284
3896
  function LoginComponent() {
3285
- const [email, setEmail] = useState10("");
3286
- const [password, setPassword] = useState10("");
3287
- const [showForm, setShowForm] = useState10(false);
3897
+ const [email, setEmail] = useState11("");
3898
+ const [password, setPassword] = useState11("");
3899
+ const [showForm, setShowForm] = useState11(false);
3288
3900
  const {
3289
3901
  isAuthenticated,
3290
3902
  isLoading,
@@ -3315,31 +3927,31 @@ function LoginComponent() {
3315
3927
  await refreshTokens();
3316
3928
  };
3317
3929
  if (isAuthenticated) {
3318
- return /* @__PURE__ */ jsxs9(Box8, { sx: { maxWidth: 600, mx: "auto", p: 3 }, children: [
3319
- /* @__PURE__ */ jsx12(Typography8, { variant: "h4", gutterBottom: true, children: "Welcome! \u{1F389}" }),
3320
- /* @__PURE__ */ jsx12(Alert7, { severity: "success", sx: { mb: 3 }, children: "You are successfully logged in with Refresh Token Pattern enabled" }),
3321
- /* @__PURE__ */ jsxs9(Box8, { sx: { mb: 3, p: 2, bgcolor: "background.paper", border: 1, borderColor: "divider", borderRadius: 1 }, children: [
3322
- /* @__PURE__ */ jsx12(Typography8, { variant: "h6", gutterBottom: true, children: "Token Status" }),
3323
- /* @__PURE__ */ jsxs9(Typography8, { variant: "body2", color: "text.secondary", children: [
3930
+ return /* @__PURE__ */ jsxs12(Box11, { sx: { maxWidth: 600, mx: "auto", p: 3 }, children: [
3931
+ /* @__PURE__ */ jsx15(Typography11, { variant: "h4", gutterBottom: true, children: "Welcome! \u{1F389}" }),
3932
+ /* @__PURE__ */ jsx15(Alert8, { severity: "success", sx: { mb: 3 }, children: "You are successfully logged in with Refresh Token Pattern enabled" }),
3933
+ /* @__PURE__ */ jsxs12(Box11, { sx: { mb: 3, p: 2, bgcolor: "background.paper", border: 1, borderColor: "divider", borderRadius: 1 }, children: [
3934
+ /* @__PURE__ */ jsx15(Typography11, { variant: "h6", gutterBottom: true, children: "Token Status" }),
3935
+ /* @__PURE__ */ jsxs12(Typography11, { variant: "body2", color: "text.secondary", children: [
3324
3936
  "Access Token expires in: ",
3325
3937
  Math.round(expiresIn / 1e3 / 60),
3326
3938
  " minutes"
3327
3939
  ] }),
3328
- isExpiringSoon && /* @__PURE__ */ jsx12(Alert7, { severity: "warning", sx: { mt: 1 }, children: "Token expires soon - automatic refresh will happen" })
3940
+ isExpiringSoon && /* @__PURE__ */ jsx15(Alert8, { severity: "warning", sx: { mt: 1 }, children: "Token expires soon - automatic refresh will happen" })
3329
3941
  ] }),
3330
- /* @__PURE__ */ jsxs9(Box8, { sx: { display: "flex", gap: 2, flexWrap: "wrap" }, children: [
3331
- /* @__PURE__ */ jsx12(
3332
- Button5,
3942
+ /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", gap: 2, flexWrap: "wrap" }, children: [
3943
+ /* @__PURE__ */ jsx15(
3944
+ Button8,
3333
3945
  {
3334
3946
  variant: "contained",
3335
3947
  onClick: handleRefreshTokens,
3336
3948
  disabled: isLoading,
3337
- startIcon: isLoading ? /* @__PURE__ */ jsx12(CircularProgress7, { size: 16 }) : null,
3949
+ startIcon: isLoading ? /* @__PURE__ */ jsx15(CircularProgress7, { size: 16 }) : null,
3338
3950
  children: "Refresh Tokens"
3339
3951
  }
3340
3952
  ),
3341
- /* @__PURE__ */ jsx12(
3342
- Button5,
3953
+ /* @__PURE__ */ jsx15(
3954
+ Button8,
3343
3955
  {
3344
3956
  variant: "outlined",
3345
3957
  color: "error",
@@ -3349,14 +3961,14 @@ function LoginComponent() {
3349
3961
  }
3350
3962
  )
3351
3963
  ] }),
3352
- error && /* @__PURE__ */ jsx12(Alert7, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
3964
+ error && /* @__PURE__ */ jsx15(Alert8, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
3353
3965
  ] });
3354
3966
  }
3355
- return /* @__PURE__ */ jsxs9(Box8, { sx: { maxWidth: 400, mx: "auto", p: 3 }, children: [
3356
- /* @__PURE__ */ jsx12(Typography8, { variant: "h4", gutterBottom: true, align: "center", children: "Login with Refresh Tokens" }),
3357
- /* @__PURE__ */ jsx12(Alert7, { severity: "info", sx: { mb: 3 }, children: "This demo shows the new Refresh Token Pattern with automatic session management" }),
3358
- !showForm ? /* @__PURE__ */ jsx12(
3359
- Button5,
3967
+ return /* @__PURE__ */ jsxs12(Box11, { sx: { maxWidth: 400, mx: "auto", p: 3 }, children: [
3968
+ /* @__PURE__ */ jsx15(Typography11, { variant: "h4", gutterBottom: true, align: "center", children: "Login with Refresh Tokens" }),
3969
+ /* @__PURE__ */ jsx15(Alert8, { severity: "info", sx: { mb: 3 }, children: "This demo shows the new Refresh Token Pattern with automatic session management" }),
3970
+ !showForm ? /* @__PURE__ */ jsx15(
3971
+ Button8,
3360
3972
  {
3361
3973
  fullWidth: true,
3362
3974
  variant: "contained",
@@ -3365,8 +3977,8 @@ function LoginComponent() {
3365
3977
  sx: { mt: 2 },
3366
3978
  children: "Show Login Form"
3367
3979
  }
3368
- ) : /* @__PURE__ */ jsxs9("form", { onSubmit: handleLogin, children: [
3369
- /* @__PURE__ */ jsx12(
3980
+ ) : /* @__PURE__ */ jsxs12("form", { onSubmit: handleLogin, children: [
3981
+ /* @__PURE__ */ jsx15(
3370
3982
  TextField5,
3371
3983
  {
3372
3984
  fullWidth: true,
@@ -3379,7 +3991,7 @@ function LoginComponent() {
3379
3991
  autoComplete: "email"
3380
3992
  }
3381
3993
  ),
3382
- /* @__PURE__ */ jsx12(
3994
+ /* @__PURE__ */ jsx15(
3383
3995
  TextField5,
3384
3996
  {
3385
3997
  fullWidth: true,
@@ -3392,37 +4004,37 @@ function LoginComponent() {
3392
4004
  autoComplete: "current-password"
3393
4005
  }
3394
4006
  ),
3395
- /* @__PURE__ */ jsx12(
3396
- Button5,
4007
+ /* @__PURE__ */ jsx15(
4008
+ Button8,
3397
4009
  {
3398
4010
  type: "submit",
3399
4011
  fullWidth: true,
3400
4012
  variant: "contained",
3401
4013
  size: "large",
3402
4014
  disabled: isLoading,
3403
- startIcon: isLoading ? /* @__PURE__ */ jsx12(CircularProgress7, { size: 16 }) : null,
4015
+ startIcon: isLoading ? /* @__PURE__ */ jsx15(CircularProgress7, { size: 16 }) : null,
3404
4016
  sx: { mt: 3, mb: 2 },
3405
4017
  children: isLoading ? "Logging in..." : "Login"
3406
4018
  }
3407
4019
  )
3408
4020
  ] }),
3409
- error && /* @__PURE__ */ jsx12(Alert7, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
4021
+ error && /* @__PURE__ */ jsx15(Alert8, { severity: "error", sx: { mt: 2 }, onClose: clearError, children: error })
3410
4022
  ] });
3411
4023
  }
3412
4024
  function SessionStatus() {
3413
4025
  const { isAuthenticated, isLoading, isExpiringSoon, expiresIn } = useSessionContext();
3414
4026
  if (isLoading) {
3415
- return /* @__PURE__ */ jsxs9(Box8, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
3416
- /* @__PURE__ */ jsx12(CircularProgress7, { size: 16 }),
3417
- /* @__PURE__ */ jsx12(Typography8, { variant: "caption", children: "Loading session..." })
4027
+ return /* @__PURE__ */ jsxs12(Box11, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
4028
+ /* @__PURE__ */ jsx15(CircularProgress7, { size: 16 }),
4029
+ /* @__PURE__ */ jsx15(Typography11, { variant: "caption", children: "Loading session..." })
3418
4030
  ] });
3419
4031
  }
3420
4032
  if (!isAuthenticated) {
3421
- return /* @__PURE__ */ jsx12(Typography8, { variant: "caption", color: "text.secondary", children: "Not logged in" });
4033
+ return /* @__PURE__ */ jsx15(Typography11, { variant: "caption", color: "text.secondary", children: "Not logged in" });
3422
4034
  }
3423
- return /* @__PURE__ */ jsxs9(Box8, { children: [
3424
- /* @__PURE__ */ jsx12(Typography8, { variant: "caption", color: "success.main", children: "\u2713 Authenticated" }),
3425
- isExpiringSoon && /* @__PURE__ */ jsxs9(Typography8, { variant: "caption", color: "warning.main", display: "block", children: [
4035
+ return /* @__PURE__ */ jsxs12(Box11, { children: [
4036
+ /* @__PURE__ */ jsx15(Typography11, { variant: "caption", color: "success.main", children: "\u2713 Authenticated" }),
4037
+ isExpiringSoon && /* @__PURE__ */ jsxs12(Typography11, { variant: "caption", color: "warning.main", display: "block", children: [
3426
4038
  "\u26A0 Token expires in ",
3427
4039
  Math.round(expiresIn / 1e3 / 60),
3428
4040
  " min"
@@ -3431,18 +4043,18 @@ function SessionStatus() {
3431
4043
  }
3432
4044
 
3433
4045
  // src/hooks/useUserData.ts
3434
- import { useState as useState11, useEffect as useEffect10, useCallback as useCallback6, useRef as useRef4 } from "react";
4046
+ import { useState as useState12, useEffect as useEffect11, useCallback as useCallback6, useRef as useRef6 } from "react";
3435
4047
  import crudify7 from "@nocios/crudify-browser";
3436
4048
  var useUserData = (options = {}) => {
3437
4049
  const { autoFetch = true, retryOnError = false, maxRetries = 3 } = options;
3438
4050
  const { isAuthenticated, isInitialized, sessionData, tokens } = useSessionContext();
3439
- const [userData, setUserData] = useState11(null);
3440
- const [loading, setLoading] = useState11(false);
3441
- const [error, setError] = useState11(null);
3442
- const abortControllerRef = useRef4(null);
3443
- const mountedRef = useRef4(true);
3444
- const requestIdRef = useRef4(0);
3445
- const retryCountRef = useRef4(0);
4051
+ const [userData, setUserData] = useState12(null);
4052
+ const [loading, setLoading] = useState12(false);
4053
+ const [error, setError] = useState12(null);
4054
+ const abortControllerRef = useRef6(null);
4055
+ const mountedRef = useRef6(true);
4056
+ const requestIdRef = useRef6(0);
4057
+ const retryCountRef = useRef6(0);
3446
4058
  const getUserEmail = useCallback6(() => {
3447
4059
  if (!sessionData) return null;
3448
4060
  return sessionData.email || sessionData["cognito:username"] || null;
@@ -3585,14 +4197,14 @@ var useUserData = (options = {}) => {
3585
4197
  }
3586
4198
  }
3587
4199
  }, [isInitialized, getUserEmail, retryOnError, maxRetries]);
3588
- useEffect10(() => {
4200
+ useEffect11(() => {
3589
4201
  if (autoFetch && isAuthenticated && isInitialized) {
3590
4202
  refreshProfile();
3591
4203
  } else if (!isAuthenticated) {
3592
4204
  clearProfile();
3593
4205
  }
3594
4206
  }, [autoFetch, isAuthenticated, isInitialized, refreshProfile, clearProfile]);
3595
- useEffect10(() => {
4207
+ useEffect11(() => {
3596
4208
  mountedRef.current = true;
3597
4209
  return () => {
3598
4210
  mountedRef.current = false;
@@ -3773,6 +4385,9 @@ export {
3773
4385
  ERROR_CODES,
3774
4386
  ERROR_SEVERITY_MAP,
3775
4387
  LoginComponent,
4388
+ POLICY_ACTIONS,
4389
+ PREFERRED_POLICY_ORDER,
4390
+ Policies_default as Policies,
3776
4391
  ProtectedRoute,
3777
4392
  SessionDebugInfo,
3778
4393
  SessionManager,