@flexkit/studio 0.2.12 → 0.2.14

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.
Files changed (94) hide show
  1. package/dist/activity-nav-button-7SVTTHBQ.js +2 -0
  2. package/dist/{activity-nav-button-LZESIQL2.js.map → activity-nav-button-7SVTTHBQ.js.map} +1 -1
  3. package/dist/astro.js +1 -1
  4. package/dist/{chat-page-EKOGKEFR.js → chat-page-L427VVVR.js} +3 -3
  5. package/dist/{chat-page-EKOGKEFR.js.map → chat-page-L427VVVR.js.map} +1 -1
  6. package/dist/chunk-2HYQVMP3.js +3 -0
  7. package/dist/chunk-2HYQVMP3.js.map +1 -0
  8. package/dist/chunk-5CVDMZUI.js +3 -0
  9. package/dist/chunk-5CVDMZUI.js.map +1 -0
  10. package/dist/chunk-6YJ3DLIU.js +2 -0
  11. package/dist/{chunk-OFJOZMCR.js.map → chunk-6YJ3DLIU.js.map} +1 -1
  12. package/dist/{chunk-BOXFB6E6.js → chunk-7ELMTFZ4.js} +2 -2
  13. package/dist/{chunk-BOXFB6E6.js.map → chunk-7ELMTFZ4.js.map} +1 -1
  14. package/dist/chunk-ALCK2BJY.js +2 -0
  15. package/dist/chunk-ALCK2BJY.js.map +1 -0
  16. package/dist/chunk-CAZ6EUR2.js +2 -0
  17. package/dist/chunk-CAZ6EUR2.js.map +1 -0
  18. package/dist/chunk-D5WYD5M4.js +2 -0
  19. package/dist/chunk-D5WYD5M4.js.map +1 -0
  20. package/dist/{chunk-2AVINVYN.js → chunk-GFAOY74A.js} +28 -18
  21. package/dist/chunk-MGXG5PWU.js +384 -0
  22. package/dist/chunk-MGXG5PWU.js.map +1 -0
  23. package/dist/{chunk-EWBEPYML.js → chunk-MJVWFANP.js} +3 -3
  24. package/dist/{chunk-EWBEPYML.js.map → chunk-MJVWFANP.js.map} +1 -1
  25. package/dist/chunk-NLRSLQUT.js +3 -0
  26. package/dist/chunk-NLRSLQUT.js.map +1 -0
  27. package/dist/{chunk-F2DHCPWW.js → chunk-P5ZRTZ5Z.js} +2 -2
  28. package/dist/{chunk-F2DHCPWW.js.map → chunk-P5ZRTZ5Z.js.map} +1 -1
  29. package/dist/{chunk-QQSI7BPK.js → chunk-R64ELY3B.js} +3 -3
  30. package/dist/{chunk-QQSI7BPK.js.map → chunk-R64ELY3B.js.map} +1 -1
  31. package/dist/chunk-U5D3EDCY.js +2 -0
  32. package/dist/chunk-U5D3EDCY.js.map +1 -0
  33. package/dist/chunk-W7Z4MY43.js +2 -0
  34. package/dist/{chunk-7IHEL6LU.js.map → chunk-W7Z4MY43.js.map} +1 -1
  35. package/dist/chunk-XWBACTNR.js +3 -0
  36. package/dist/{chunk-C47FNPLK.js.map → chunk-XWBACTNR.js.map} +1 -1
  37. package/dist/chunk-ZZRA4567.js +2 -0
  38. package/dist/{chunk-V64P56OA.js.map → chunk-ZZRA4567.js.map} +1 -1
  39. package/dist/electron.d.ts +103 -0
  40. package/dist/electron.js +131 -0
  41. package/dist/index.css +9 -0
  42. package/dist/index.d.ts +33 -1
  43. package/dist/index.js +9 -9
  44. package/dist/index.js.map +1 -1
  45. package/dist/list-WJLU3K2X.js +2 -0
  46. package/dist/{list-DOTORSUC.js.map → list-WJLU3K2X.js.map} +1 -1
  47. package/dist/nextjs.js +1 -1
  48. package/dist/{pages-ILAXYS2J.js → pages-3EK5GS2T.js} +4 -4
  49. package/dist/{pages-ILAXYS2J.js.map → pages-3EK5GS2T.js.map} +1 -1
  50. package/dist/plugin-pages-PQO22EOE.js +2 -0
  51. package/dist/{plugin-pages-RKJRHKNL.js.map → plugin-pages-PQO22EOE.js.map} +1 -1
  52. package/dist/root-4EALW3G6.js +2 -0
  53. package/dist/{root-RE3ZNXQ3.js.map → root-4EALW3G6.js.map} +1 -1
  54. package/dist/root-BA7BLCFR.js +23 -0
  55. package/dist/root-BA7BLCFR.js.map +1 -0
  56. package/dist/root-YNGCF5QM.js +31 -0
  57. package/dist/{root-JB3NZZNZ.js.map → root-YNGCF5QM.js.map} +1 -1
  58. package/dist/root-ZF62TR5Z.js +2 -0
  59. package/dist/{root-76YQTZUI.js.map → root-ZF62TR5Z.js.map} +1 -1
  60. package/dist/search-QHMCAT7O.js +2 -0
  61. package/dist/{search-WUO6VWKU.js.map → search-QHMCAT7O.js.map} +1 -1
  62. package/dist/skills-pages-HIBSAVOP.js +2 -0
  63. package/dist/{skills-pages-POKCFHOL.js.map → skills-pages-HIBSAVOP.js.map} +1 -1
  64. package/dist/tanstack-start.js +1 -1
  65. package/dist/user-nav-36ACWXOW.js +2 -0
  66. package/dist/{user-nav-DCAHVWN7.js.map → user-nav-36ACWXOW.js.map} +1 -1
  67. package/package.json +10 -6
  68. package/dist/activity-nav-button-LZESIQL2.js +0 -2
  69. package/dist/chunk-2HSIWUH3.js +0 -3
  70. package/dist/chunk-2HSIWUH3.js.map +0 -1
  71. package/dist/chunk-6YOVF2AD.js +0 -384
  72. package/dist/chunk-6YOVF2AD.js.map +0 -1
  73. package/dist/chunk-7IHEL6LU.js +0 -2
  74. package/dist/chunk-ACS3TGGP.js +0 -2
  75. package/dist/chunk-ACS3TGGP.js.map +0 -1
  76. package/dist/chunk-C47FNPLK.js +0 -3
  77. package/dist/chunk-HYSTMQD7.js +0 -2
  78. package/dist/chunk-HYSTMQD7.js.map +0 -1
  79. package/dist/chunk-KXAGLQ2B.js +0 -2
  80. package/dist/chunk-KXAGLQ2B.js.map +0 -1
  81. package/dist/chunk-OFJOZMCR.js +0 -2
  82. package/dist/chunk-TYDYAOQ7.js +0 -3
  83. package/dist/chunk-TYDYAOQ7.js.map +0 -1
  84. package/dist/chunk-V64P56OA.js +0 -2
  85. package/dist/list-DOTORSUC.js +0 -2
  86. package/dist/plugin-pages-RKJRHKNL.js +0 -2
  87. package/dist/root-76YQTZUI.js +0 -2
  88. package/dist/root-A4VHAEK5.js +0 -23
  89. package/dist/root-A4VHAEK5.js.map +0 -1
  90. package/dist/root-JB3NZZNZ.js +0 -31
  91. package/dist/root-RE3ZNXQ3.js +0 -2
  92. package/dist/search-WUO6VWKU.js +0 -2
  93. package/dist/skills-pages-POKCFHOL.js +0 -2
  94. package/dist/user-nav-DCAHVWN7.js +0 -2
@@ -1,2 +0,0 @@
1
- import'./index.css';import {c,e as e$1}from'./chunk-P6BZ4QP7.js';import {f}from'./chunk-C47FNPLK.js';import {e}from'./chunk-TYDYAOQ7.js';import {useMemo}from'react';import A from'swr';import {find,propEq}from'ramda';function T(n,i){let{scope:c$1}=c(),{currentProject:e$1}=f(),o=useMemo(()=>e$1?.schema??[],[e$1]),a=e$1?.scopes?.find(t=>t.isDefault)?.name??"default",m=i?.commonParams.q?JSON.stringify(i):null,{data:r,error:s,isLoading:y}=A(m,()=>fetch(e(n).search,{headers:{"Content-Type":"application/json"},body:JSON.stringify(i),method:"POST",mode:"cors"}).then(t=>t.json()));return {results:useMemo(()=>E(r?.results??[],n,o,c$1,a)??[],[r,a,n,o,c$1]),error:s,isLoading:y}}function E(n,i,c,e,o){return n?.filter(l=>l?.hits?.length>0).map(l=>{let a=l,m=a.collection.replace(`${i}_`,"").replace(/_\d+$/,""),r=find(propEq(m,"plural"))(c);if(!r)return [];let s=e$1(r)?.name??"",y=r?.name??m;return a.hits.map(({document:u})=>{let t=u[s],b=(t&&typeof t!="string"?t[e]??t[o]:null)??u[s],N=Object.entries(u).reduce((d,[p,f])=>{if(p!==s&&p!=="id"&&p!=="_updatedAt"){let _=typeof f!="string"?f[e]??f[o]:f;d[p]=_;}return d},{});return {_id:u.id,_entityName:y,_entityNamePlural:m,[s]:b,...N}})}).flat()}export{T as a};//# sourceMappingURL=chunk-7IHEL6LU.js.map
2
- //# sourceMappingURL=chunk-7IHEL6LU.js.map
@@ -1,2 +0,0 @@
1
- import'./index.css';import {d}from'./chunk-TYDYAOQ7.js';import {createContext,useState,useEffect,useContext}from'react';import m from'swr';var v=createContext(true);function A(){return useContext(v)}function f(){return typeof document>"u"||document.visibilityState==="visible"&&document.hasFocus()}function P(){let e=A(),[i,n]=useState(f);return useEffect(()=>{let t=()=>n(f());return t(),window.addEventListener("focus",t),window.addEventListener("blur",t),document.addEventListener("visibilitychange",t),()=>{window.removeEventListener("focus",t),window.removeEventListener("blur",t),document.removeEventListener("visibilitychange",t);}},[]),e&&i}var g="1970-01-01T00:00:00.000Z";function T(e){return e.chatId?`agent/chats/${e.chatId}`:e.automationId&&e.automationRunId?`automations/${e.automationId}/runs/${e.automationRunId}`:null}function R(e){return e.chatId?"View chat":e.automationId&&e.automationRunId?"View run":null}var b={answered:"Answered",approved:"Approved",cancelled:"Cancelled",dismissed:"Dismissed",expired:"Expired",rejected:"Rejected"};function k(e){return e.kind==="automation_failure"?"Failed":e.kind==="automation_result"?"Result":e.kind==="monitor_event"?"Monitor":e.resolution?b[e.resolution]:!e.requiresAction||e.state==="done"||e.state==="dismissed"?null:e.kind==="question"?"Needs answer":"Needs approval"}function L(e){return e.kind==="automation_failure"?"failure":I(e)?"attention":"neutral"}function I(e){return e.requiresAction&&e.resolvedAt===null&&e.state!=="dismissed"&&e.state!=="done"}function O({mutedKinds:e=[],newItems:i,since:n}){let t=i.reduce((o,u)=>o===null||u.createdAt>o?u.createdAt:o,null);if(n===null)return {notifications:[],since:t??g};let r=i.filter(o=>o.createdAt>n&&!e.includes(o.kind)),a=t!==null&&t>n?t:n;return r.length===0?{notifications:[],since:a}:r.length>3?{notifications:[{body:"Open Activity in Flexkit Studio to review them.",path:"activity",tag:`flexkit-activity-batch:${a}`,title:`${r.length.toString()} new items in Activity`}],since:a}:{notifications:r.map(o=>({body:o.body??"",path:`activity/${encodeURIComponent(o.id)}`,tag:`flexkit-activity:${o.id}`,title:o.title})),since:a}}var h={approvalEmail:true,desktopMutedKinds:[]};async function c(e,i){let n=await fetch(e,{credentials:"same-origin",...i,headers:{"Content-Type":"application/json",...i?.headers}});if(!n.ok)throw new Error(`Request failed with ${n.status.toString()}.`);return await n.json()}function F(){let{data:e,error:i,mutate:n}=m(d.notificationPreferences,t=>c(t));return {isLoaded:e!==void 0||i!==void 0,mutate:n,preferences:e?.preferences??h}}function $(e){return c(d.notificationPreferences,{body:JSON.stringify(e),method:"PUT"})}function w(){return typeof window<"u"&&typeof Notification<"u"&&"serviceWorker"in navigator&&"PushManager"in window}function N(e){let i=`${e}${"=".repeat((4-e.length%4)%4)}`.replace(/-/g,"+").replace(/_/g,"/"),n=atob(i),t=new Uint8Array(new ArrayBuffer(n.length));for(let r=0;r<n.length;r+=1)t[r]=n.charCodeAt(r);return t}async function M(){if(!w()||Notification.permission!=="granted")return false;let{publicKey:e}=await c(d.push);if(!e)return false;await navigator.serviceWorker.register("/sw.js",{scope:"/"});let{pushManager:i}=await navigator.serviceWorker.ready,n=N(e),t=await i.getSubscription();return t&&!S(t.options.applicationServerKey,n)&&(await t.unsubscribe(),t=null),t??=await i.subscribe({applicationServerKey:n,userVisibleOnly:true}),await c(d.push,{body:JSON.stringify(t.toJSON()),method:"POST"}),true}function S(e,i){return !e||e.byteLength!==i.byteLength?false:new Uint8Array(e).every((t,r)=>t===i[r])}export{v as a,P as b,T as c,R as d,k as e,L as f,I as g,O as h,F as i,$ as j,M as k};//# sourceMappingURL=chunk-ACS3TGGP.js.map
2
- //# sourceMappingURL=chunk-ACS3TGGP.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/apps/app-active.ts","../src/apps/ai/activity.ts","../src/apps/ai/notification-settings.ts"],"names":["AppActiveContext","createContext","useIsAppActive","useContext","isWindowInFront","useIsViewing","isAppActive","isInFront","setIsInFront","useState","useEffect","update","EPOCH","getActivitySourcePath","item","getActivitySourceLabel","RESOLUTION_LABELS","getActivityStatusLabel","getActivityStatusTone","isActivityItemOpen","planActivityNotifications","mutedKinds","newItems","since","newest","latest","fresh","nextSince","DEFAULT_NOTIFICATION_PREFERENCES","userRequest","url","init","response","useNotificationPreferences","data","error","mutate","useSWR","userApiPaths","saveNotificationPreferences","preferences","isWebPushSupported","decodeApplicationServerKey","base64Url","base64","binary","bytes","index","ensurePushSubscription","publ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AAQ,CAAA,CAAG,MAAA,CAAQ,MAAO,CAAC,CAAA,CAE7F,IACT,CAEA,SAASC,CAAAA,CAAQC,EAA6BC,CAAAA,CAA+B,CAC3E,OAAI,CAACD,GAAWA,CAAAA,CAAQ,UAAA,GAAeC,EAAS,UAAA,CACvC,KAAA,CAGK,IAAI,UAAA,CAAWD,CAAO,CAAA,CAEvB,KAAA,CAAM,CAACE,CAAAA,CAAMT,CAAAA,GAAUS,IAASD,CAAAA,CAASR,CAAK,CAAC,CAC9D","file":"chunk-ACS3TGGP.js","sourcesContent":["import { createContext, useContext, useEffect, useState } from 'react';\n\n/**\n * Whether the app around a component is the one in front. Opened apps stay\n * mounted behind the active one (see `AppOutlet`), so their effects keep\n * running; this tells them apart. Outside an app it is `true`.\n */\nexport const AppActiveContext = createContext(true);\n\nexport function useIsAppActive(): boolean {\n return useContext(AppActiveContext);\n}\n\nfunction isWindowInFront(): boolean {\n return typeof document === 'undefined' || (document.visibilityState === 'visible' && document.hasFocus());\n}\n\n/**\n * The person is looking at this app right now: it is the app in front, the\n * tab is visible and the browser window has focus.\n */\nexport function useIsViewing(): boolean {\n const isAppActive = useIsAppActive();\n const [isInFront, setIsInFront] = useState(isWindowInFront);\n\n useEffect(() => {\n const update = (): void => setIsInFront(isWindowInFront());\n\n update();\n window.addEventListener('focus', update);\n window.addEventListener('blur', update);\n document.addEventListener('visibilitychange', update);\n\n return () => {\n window.removeEventListener('focus', update);\n window.removeEventListener('blur', update);\n document.removeEventListener('visibilitychange', update);\n };\n }, []);\n\n return isAppActive && isInFront;\n}\n","import type { ActivityItem, ActivityItemKind, ActivityItemResolution } from './types';\n\n/** More new items than this in one poll are announced by a single summary notification. */\nconst MAX_SEPARATE_NOTIFICATIONS = 3;\n\n/** Watermark before the first item exists: every later unread item is new. */\nconst EPOCH = '1970-01-01T00:00:00.000Z';\n\nexport interface ActivityNotification {\n body: string;\n /** AI-app relative path opened on click, e.g. `activity/<id>`. */\n path: string;\n /** Same tag = same notification across tabs and repeated polls. */\n tag: string;\n title: string;\n}\n\n/** Path, relative to the AI app, of the chat or run an item came from. */\nexport function getActivitySourcePath(item: ActivityItem): string | null {\n if (item.chatId) {\n return `agent/chats/${item.chatId}`;\n }\n\n if (item.automationId && item.automationRunId) {\n return `automations/${item.automationId}/runs/${item.automationRunId}`;\n }\n\n return null;\n}\n\nexport function getActivitySourceLabel(item: ActivityItem): string | null {\n if (item.chatId) {\n return 'View chat';\n }\n\n return item.automationId && item.automationRunId ? 'View run' : null;\n}\n\nconst RESOLUTION_LABELS: { [key in ActivityItemResolution]: string } = {\n answered: 'Answered',\n approved: 'Approved',\n cancelled: 'Cancelled',\n dismissed: 'Dismissed',\n expired: 'Expired',\n rejected: 'Rejected',\n};\n\n/** Short status for a row: what happened to it, or that it still waits on the viewer. */\nexport function getActivityStatusLabel(item: ActivityItem): string | null {\n if (item.kind === 'automation_failure') {\n return 'Failed';\n }\n\n if (item.kind === 'automation_result') {\n return 'Result';\n }\n\n if (item.kind === 'monitor_event') {\n return 'Monitor';\n }\n\n if (item.resolution) {\n return RESOLUTION_LABELS[item.resolution];\n }\n\n if (!item.requiresAction || item.state === 'done' || item.state === 'dismissed') {\n return null;\n }\n\n return item.kind === 'question' ? 'Needs answer' : 'Needs approval';\n}\n\n/** How a row's status badge reads: waiting on the viewer, a failure, or neutral. */\nexport function getActivityStatusTone(item: ActivityItem): 'attention' | 'failure' | 'neutral' {\n if (item.kind === 'automation_failure') {\n return 'failure';\n }\n\n return isActivityItemOpen(item) ? 'attention' : 'neutral';\n}\n\n/** True while the item still waits on the viewer. */\nexport function isActivityItemOpen(item: ActivityItem): boolean {\n return item.requiresAction && item.resolvedAt === null && item.state !== 'dismissed' && item.state !== 'done';\n}\n\n/**\n * Turns one summary poll into desktop notifications and the next watermark.\n * The first poll (no watermark yet) only seeds it, so opening Studio never\n * replays notifications for items the user already had.\n */\nexport function planActivityNotifications({\n mutedKinds = [],\n newItems,\n since,\n}: {\n /** Kinds the viewer turned off for desktop notifications; they still move the watermark. */\n mutedKinds?: ActivityItemKind[];\n newItems: ActivityItem[];\n since: string | null;\n}): { notifications: ActivityNotification[]; since: string } {\n const newest = newItems.reduce<string | null>(\n (latest, item) => (latest === null || item.createdAt > latest ? item.createdAt : latest),\n null\n );\n\n if (since === null) {\n return { notifications: [], since: newest ?? EPOCH };\n }\n\n const fresh = newItems.filter((item) => item.createdAt > since && !mutedKinds.includes(item.kind));\n const nextSince = newest !== null && newest > since ? newest : since;\n\n if (fresh.length === 0) {\n return { notifications: [], since: nextSince };\n }\n\n if (fresh.length > MAX_SEPARATE_NOTIFICATIONS) {\n return {\n notifications: [\n {\n body: 'Open Activity in Flexkit Studio to review them.',\n path: 'activity',\n tag: `flexkit-activity-batch:${nextSince}`,\n title: `${fresh.length.toString()} new items in Activity`,\n },\n ],\n since: nextSince,\n };\n }\n\n return {\n notifications: fresh.map((item) => ({\n body: item.body ?? '',\n path: `activity/${encodeURIComponent(item.id)}`,\n tag: `flexkit-activity:${item.id}`,\n title: item.title,\n })),\n since: nextSince,\n };\n}\n","import useSWR, { type KeyedMutator } from 'swr';\nimport { userApiPaths } from '../../core/api-paths';\nimport type { ActivityItemKind } from './types';\n\n/** A person's notification choices, shared by every project they open. */\nexport interface NotificationPreferences {\n /** Email an approval request left unread past the project's delay. */\n approvalEmail: boolean;\n /** Kinds that never raise a desktop notification. */\n desktopMutedKinds: ActivityItemKind[];\n}\n\nexport const DEFAULT_NOTIFICATION_PREFERENCES: NotificationPreferences = { approvalEmail: true, desktopMutedKinds: [] };\n\nasync function userRequest<T>(url: string, init?: RequestInit): Promise<T> {\n const response = await fetch(url, {\n credentials: 'same-origin',\n ...init,\n headers: { 'Content-Type': 'application/json', ...init?.headers },\n });\n\n if (!response.ok) {\n throw new Error(`Request failed with ${response.status.toString()}.`);\n }\n\n return (await response.json()) as T;\n}\n\nexport function useNotificationPreferences(): {\n /** False until the stored preferences arrived (or could not be loaded, which means the defaults). */\n isLoaded: boolean;\n mutate: KeyedMutator<{ preferences: NotificationPreferences }>;\n preferences: NotificationPreferences;\n} {\n const { data, error, mutate } = useSWR<{ preferences: NotificationPreferences }>(\n userApiPaths.notificationPreferences,\n (url: string) => userRequest<{ preferences: NotificationPreferences }>(url)\n );\n\n return {\n isLoaded: data !== undefined || error !== undefined,\n mutate,\n preferences: data?.preferences ?? DEFAULT_NOTIFICATION_PREFERENCES,\n };\n}\n\nexport function saveNotificationPreferences(preferences: NotificationPreferences): Promise<{ preferences: NotificationPreferences }> {\n return userRequest(userApiPaths.notificationPreferences, { body: JSON.stringify(preferences), method: 'PUT' });\n}\n\nexport function isWebPushSupported(): boolean {\n return (\n typeof window !== 'undefined' &&\n typeof Notification !== 'undefined' &&\n 'serviceWorker' in navigator &&\n 'PushManager' in window\n );\n}\n\n/** The VAPID public key as the bytes `PushManager.subscribe` expects. */\nexport function decodeApplicationServerKey(base64Url: string): Uint8Array<ArrayBuffer> {\n const base64 = `${base64Url}${'='.repeat((4 - (base64Url.length % 4)) % 4)}`.replace(/-/g, '+').replace(/_/g, '/');\n const binary = atob(base64);\n const bytes = new Uint8Array(new ArrayBuffer(binary.length));\n\n for (let index = 0; index < binary.length; index += 1) {\n bytes[index] = binary.charCodeAt(index);\n }\n\n return bytes;\n}\n\n/**\n * Hosted Studio only: registers the service worker and saves this browser's\n * push subscription for the signed-in user, so Activity items arrive while no\n * Studio tab is open. Needs notification permission; never asks for it.\n * Safe to call on every load: an existing subscription is saved again.\n * Returns false when Web Push is unavailable here.\n */\nexport async function ensurePushSubscription(): Promise<boolean> {\n if (!isWebPushSupported() || Notification.permission !== 'granted') {\n return false;\n }\n\n const { publicKey } = await userRequest<{ publicKey: string | null }>(userApiPaths.push);\n\n if (!publicKey) {\n return false;\n }\n\n await navigator.serviceWorker.register('/sw.js', { scope: '/' });\n\n const { pushManager } = await navigator.serviceWorker.ready;\n const applicationServerKey = decodeApplicationServerKey(publicKey);\n let subscription = await pushManager.getSubscription();\n\n // A subscription made with an older key would never receive again.\n if (subscription && !sameKey(subscription.options.applicationServerKey, applicationServerKey)) {\n await subscription.unsubscribe();\n subscription = null;\n }\n\n subscription ??= await pushManager.subscribe({ applicationServerKey, userVisibleOnly: true });\n\n await userRequest(userApiPaths.push, { body: JSON.stringify(subscription.toJSON()), method: 'POST' });\n\n return true;\n}\n\nfunction sameKey(current: ArrayBuffer | null, expected: Uint8Array): boolean {\n if (!current || current.byteLength !== expected.byteLength) {\n return false;\n }\n\n const bytes = new Uint8Array(current);\n\n return bytes.every((byte, index) => byte === expected[index]);\n}\n"]}
@@ -1,3 +0,0 @@
1
- import'./index.css';import {h,e}from'./chunk-TYDYAOQ7.js';import {b as b$1}from'./chunk-U45E5X3H.js';import {createContext,lazy,Suspense,useMemo,useContext}from'react';import {Navigate,useParams}from'react-router-dom';import {Bot,Layout,FileStack,SquarePlay}from'lucide-react';import {jsx,jsxs}from'react/jsx-runtime';import C,{mutate}from'swr';var d={name:"_asset",plural:"_assets",display:"originalFilename",menu:{hidden:true},attributes:[{name:"path",label:"Asset",scope:"global",options:{size:140},dataType:"string",inputType:"text",previewType:"assetPreviewField",defaultValue:""},{name:"originalFilename",label:"Filename",scope:"global",options:{size:320},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"size",label:"Size",scope:"global",options:{size:120},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"width",label:"Width",scope:"global",options:{size:90},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"height",label:"Height",scope:"global",options:{size:100},dataType:"int",inputType:"text",previewType:"text",defaultValue:""},{name:"mimeType",label:"Mime Type",scope:"global",options:{size:160},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"lqip",label:"lqip",scope:"global",hidden:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"url",label:"URL",scope:"global",hidden:true,readOnly:true,dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Updated At",scope:"global",options:{size:220},readOnly:true,hidden:true,dataType:"datetime",inputType:"datetime",previewType:"datetime",defaultValue:""},{name:"tags",label:"Tags",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",previewType:"tags",options:{size:300},relationship:{mode:"multiple",field:"name",entity:"_tag"}}]};var f={name:"_tag",plural:"_tags",display:"name",menu:{hidden:true},attributes:[{name:"name",label:"Tag Name",scope:"global",options:{size:220},dataType:"string",inputType:"text",previewType:"text",defaultValue:""},{name:"_updatedAt",label:"Updated At",scope:"global",options:{size:220},readOnly:true,hidden:true,dataType:"datetime",inputType:"datetime",previewType:"datetime",defaultValue:""},{name:"assets",label:"Assets",scope:"relationship",dataType:"string",inputType:"relationship",defaultValue:"",relationship:{mode:"multiple",field:"originalFilename",entity:"_asset"}}]};function x(){let{resolvedTheme:e}=b$1();return jsx("div",{className:"fk:flex fk:w-full fk:h-full fk:justify-center fk:items-center fk:bg-background",children:jsxs("div",{className:"fk:flex fk:flex-col fk:items-center",children:[e==="dark"?jsxs("svg",{className:"fk:h-8 fk:w-8 fk:animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"#020817"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"white"})]}):jsxs("svg",{className:"fk:h-8 fk:w-8 fk:animate-bounce",fill:"none",viewBox:"0 0 48 48",xmlns:"http://www.w3.org/2000/svg",children:[jsx("path",{d:"M7 8H41V40H7V8Z",fill:"white"}),jsx("path",{d:"M24 0C42 0 48 6 48 24C48 42 42 48 24 48C6 48 0 42 0 24C0 6 6 0 24 0ZM17.7494 9.52381H8.7619L19.2833 23.8313L8.7619 38.7078H17.7494L21.0499 33.6639V14.2549L17.7494 9.52381ZM38.9577 9.52381H29.9542L26.2857 14.8229V33.0406L29.9542 38.7078H38.9577L28.3908 23.8313L38.9577 9.52381Z",fill:"#020817"})]}),jsx("div",{className:"fk:text-foreground fk:text-center fk:mt-4 fk:animate-pulse",children:"Loading..."})]})})}var _=Navigate;function o(e){let t=lazy(e);return jsx(Suspense,{fallback:jsx(x,{}),children:jsx(t,{})})}var B=o(()=>import('./root-RE3ZNXQ3.js').then(e=>({default:e.Root}))),J=o(()=>import('./list-DOTORSUC.js').then(e=>({default:e.List}))),W=o(()=>import('./edit-entity-PVT34FD7.js').then(e=>({default:e.EditEntity}))),X=o(()=>import('./root-A4VHAEK5.js').then(e=>({default:e.Root}))),q=o(()=>import('./root-JB3NZZNZ.js').then(e=>({default:e.Root}))),K=o(()=>import('./root-76YQTZUI.js').then(e=>({default:e.Root}))),$=o(()=>import('./plugin-pages-RKJRHKNL.js').then(e=>({default:e.PluginsPage}))),G=o(()=>import('./plugin-pages-RKJRHKNL.js').then(e=>({default:e.InstalledPluginsPage}))),Q=o(()=>import('./plugin-pages-RKJRHKNL.js').then(e=>({default:e.PluginDetailPage}))),T=o(()=>import('./chat-page-EKOGKEFR.js').then(e=>({default:e.AgentChatPage}))),Y=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.AutomationsPage}))),ee=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.RunHistoryPage}))),te=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.ApprovalsPage}))),oe=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.ActivityPage}))),ae=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.ActivityItemPage}))),ne=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.CreateAutomationPage}))),ie=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.AutomationDetailPage}))),re=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.RunsPage}))),se=o(()=>import('./pages-ILAXYS2J.js').then(e=>({default:e.RunDetailPage}))),pe=o(()=>import('./skills-pages-POKCFHOL.js').then(e=>({default:e.SkillsPage}))),ce=o(()=>import('./skills-pages-POKCFHOL.js').then(e=>({default:e.CreateSkillPage}))),le=o(()=>import('./skills-pages-POKCFHOL.js').then(e=>({default:e.SkillDetailPage}))),l=[{name:"ai",icon:jsx(Bot,{strokeWidth:1.5}),title:"AI",component:K,routes:[{path:"plugins",component:$},{path:"plugins/installed",component:G},{path:"plugins/:pluginId",component:Q},{component:jsx(_,{replace:true,to:"agent"}),path:""},{component:T,path:"agent"},{component:T,path:"agent/chats/:chatId"},{component:Y,path:"automations"},{component:ee,path:"runs"},{component:te,path:"approvals"},{component:oe,path:"activity"},{component:ae,path:"activity/:itemId"},{component:ne,path:"automations/new"},{component:ie,path:"automations/:automationId"},{component:re,path:"automations/:automationId/runs"},{component:se,path:"automations/:automationId/runs/:runId"},{component:pe,path:"skills"},{component:ce,path:"skills/new"},{component:le,path:"skills/:skillId"}]},{name:"desk",icon:jsx(Layout,{strokeWidth:1.5}),title:"Desk",component:B,routes:[{path:"list/:entity",component:J,children:[{path:"edit/:id",component:W}]}]},{name:"asset-manager",icon:jsx(FileStack,{strokeWidth:1.5}),title:"Asset Manager",component:X,routes:[]},{name:"explorer",icon:jsx(SquarePlay,{strokeWidth:1.5}),title:"Explorer",component:q,routes:[]}];async function b(e$1){try{let t=await fetch(e(e$1).schema,{credentials:"include",mode:"cors"});if(!t.ok){let n=t.statusText||`Request failed with status ${String(t.status)}`;try{let i=await t.json();n=i.error??i.message??n;}catch{}return {ok:!1,projectId:e$1,error:{status:t.status,message:n}}}let a=await t.json();return {ok:!0,project:{...a,projectId:a.projectId||e$1}}}catch(t){return {ok:false,projectId:e$1,error:{status:0,message:t instanceof Error?t.message:"Network error"}}}}function w(e,t){let a=[],n={};for(let i of e??[])i.ok?a.push(i.project):n[i.projectId]=i.error;return {projects:a,errors:n,isLoading:t}}function A(e,t){let a=t&&e.length>0?["project-schemas",t,...e]:null,{data:n,isLoading:i}=C(a,()=>Promise.all(e.map(s=>b(s))),{revalidateOnFocus:false,revalidateOnReconnect:false});return w(n,!!a&&(i||n===void 0))}function ue(e,t){return w(e?[e]:void 0,t)}function L(e,t){let a=t&&e?["project-schema",t,e]:null,{data:n,isLoading:i}=C(a,()=>b(e??""),{revalidateOnFocus:false,revalidateOnReconnect:false});return ue(n,!!a&&(i||n===void 0))}function de(e,t){return Array.isArray(e)&&(e[0]==="project-schema"||e[0]==="project-schemas")&&e.slice(2).includes(t)}function Re(e){return mutate(t=>de(t,e))}var I=createContext({mode:"projects",apps:l,contributions:{apps:l},currentProjectId:void 0,currentProject:void 0,currentProjectSchema:[],projects:[],projectIds:[],projectSummaries:[],schemaErrors:{},isLoadingSchemas:false});function ye(e){return [...e.filter(a=>a.name!==d.name&&a.name!==f.name),d,f]}function De({projectIds:e,projectSummaries:t=[],mode:a="projects",userId:n,children:i}){let{projectId:s}=useParams(),[,R]=h(),h$1=R.user?.id??n,V=A(a==="projects"?e:[],h$1),O=L(a==="hosted"&&s&&e.includes(s)?s:void 0,h$1),{projects:y,errors:P,isLoading:S}=a==="hosted"?O:V,m=useMemo(()=>e.map(r=>y.find(u=>u.projectId===r)).filter(r=>r!==void 0).map(r=>({...r,schema:ye(r.schema)})),[y,e]),H=useMemo(()=>{let r=m.find(u=>u.projectId===s);return {mode:a,apps:l,contributions:{apps:l},currentProjectId:s,currentProject:r,currentProjectSchema:r?.schema??[],projects:m,projectIds:e,projectSummaries:t,schemaErrors:P,isLoadingSchemas:S}},[s,P,S,a,e,t,m]);return jsx(I.Provider,{value:H,children:i})}function Ze(){return useContext(I)}
2
- export{x as a,d as b,f as c,Re as d,De as e,Ze as f};//# sourceMappingURL=chunk-C47FNPLK.js.map
3
- //# sourceMappingURL=chunk-C47FNPLK.js.map
@@ -1,2 +0,0 @@
1
- import'./index.css';import {g as g$1,f}from'./chunk-2HSIWUH3.js';import {a,b,c,e}from'./chunk-USNXQOMJ.js';import {b as b$1}from'./chunk-6NRQMG26.js';import {BellIcon}from'lucide-react';import {Link}from'react-router-dom';import v from'swr';import {jsx,jsxs}from'react/jsx-runtime';function g(t){let{data:o}=v(t?g$1(t).activitySummary():null,f,{refreshInterval:3e4});return o}function n(t){return t>99?"99+":t.toString()}function x({projectId:t}){let o=g(t),e$1=o?.needsActionCount??0,r=o?.unreadCount??0,f=e$1>0?`Activity: ${n(e$1)} waiting for you`:r>0?`Activity: ${n(r)} unread`:"Activity";return jsx(a,{children:jsxs(b,{children:[jsx(c,{asChild:true,children:jsx(b$1,{asChild:true,"aria-label":f,className:"fk:relative fk:h-8 fk:w-8 fk:rounded-full",size:"icon",variant:"ghost",children:jsxs(Link,{to:`/${t}/ai/activity`,children:[jsx(BellIcon,{className:"fk:size-4"}),e$1>0?jsx("span",{className:"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white",children:n(e$1)}):r>0?jsx("span",{className:"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success"}):null]})})}),jsx(e,{children:f})]})})}export{g as a,x as b};//# sourceMappingURL=chunk-HYSTMQD7.js.map
2
- //# sourceMappingURL=chunk-HYSTMQD7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/apps/ai/activity-nav-button.tsx"],"names":["useActivitySummary","projectId","data","useSWR","paths","fetcher","formatCount","count","ActivityNavButton","summary","needsAction","unread","label","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Button","Link","BellIcon","TooltipContent"],"mappings":"0RAaO,SAASA,CAAAA,CAAmBC,CAAAA,CAA4D,CAC7F,GAAM,CAAE,IAAA,CAAAC,CAAK,CAAA,CAAIC,EAAwBF,CAAAA,CAAYG,GAAAA,CAAMH,CAAS,CAAA,CAAE,iBAAgB,CAAI,IAAA,CAAMI,EAA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AA,CAA0E,EACxF,IAAA,CAAA,CACN,CAAA,CACF,CAAA,CACF,CAAA,CACAA,IAACQ,CAAAA,CAAA,CAAgB,SAAAT,CAAAA,CAAM,CAAA,CAAA,CACzB,EACF,CAEJ","file":"chunk-HYSTMQD7.js","sourcesContent":["import type { JSX } from 'react';\nimport { BellIcon } from 'lucide-react';\nimport { Link } from 'react-router-dom';\nimport useSWR from 'swr';\nimport { Button } from '../../ui/primitives/button';\nimport { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/primitives/tooltip';\nimport { fetcher, paths } from './api';\nimport type { ActivitySummary } from './types';\n\n/**\n * The project's Activity badge counts. `ActivityNotifier` refreshes the same\n * SWR key on every poll, so every reader stays in sync with one request.\n */\nexport function useActivitySummary(projectId: string | undefined): ActivitySummary | undefined {\n const { data } = useSWR<ActivitySummary>(projectId ? paths(projectId).activitySummary() : null, fetcher, {\n refreshInterval: 30_000,\n });\n\n return data;\n}\n\nfunction formatCount(count: number): string {\n return count > 99 ? '99+' : count.toString();\n}\n\n/** Navbar shortcut to Activity, so pending items are visible from every app. */\nexport function ActivityNavButton({ projectId }: { projectId: string }): JSX.Element {\n const summary = useActivitySummary(projectId);\n const needsAction = summary?.needsActionCount ?? 0;\n const unread = summary?.unreadCount ?? 0;\n const label =\n needsAction > 0\n ? `Activity: ${formatCount(needsAction)} waiting for you`\n : unread > 0\n ? `Activity: ${formatCount(unread)} unread`\n : 'Activity';\n\n return (\n <TooltipProvider>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button asChild aria-label={label} className=\"fk:relative fk:h-8 fk:w-8 fk:rounded-full\" size=\"icon\" variant=\"ghost\">\n <Link to={`/${projectId}/ai/activity`}>\n <BellIcon className=\"fk:size-4\" />\n {needsAction > 0 ? (\n <span className=\"fk:absolute fk:-right-1 fk:-top-1 fk:flex fk:h-4 fk:min-w-4 fk:items-center fk:justify-center fk:rounded-full fk:bg-amber-500 fk:px-1 fk:text-[0.625rem] fk:font-semibold fk:leading-none fk:text-white\">\n {formatCount(needsAction)}\n </span>\n ) : unread > 0 ? (\n <span className=\"fk:absolute fk:right-1 fk:top-1 fk:size-2 fk:rounded-full fk:bg-success\" />\n ) : null}\n </Link>\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n"]}
@@ -1,2 +0,0 @@
1
- import'./index.css';import {b}from'./chunk-2HSIWUH3.js';var T="/plugins/oauth/start",g=class extends Error{code="account_mismatch";constructor(){super('You signed in with a different account. Use "Connect another account" to add it.'),this.name="PluginAccountMismatchError";}};function y(o){let e;try{e=new URL(o);}catch{return null}return e.protocol!=="https:"||e.username!==""||e.password!==""?null:e}function E(o,e){let s=b(),r=y(o),n=y(e);return !r||!n||r.origin!==s||r.pathname!==T||n.origin!==s||n.pathname!=="/"?null:{href:r.href,origin:s}}async function C(o,e,s,r){let n=window.open("about:blank",`flexkit-plugin-${crypto.randomUUID()}`,"popup,width=560,height=720");if(!n)throw new Error("Allow popups for Studio, then connect again.");let i;try{i=await o.connectPlugins({pluginId:e,scope:s,studioOrigin:window.location.origin,...r?.connectionId?{connectionId:r.connectionId}:{}});}catch(d){throw n.close(),d}let l=E(i.authorizeUrl,i.completionOrigin);if(!l)throw n.close(),new Error("Connection could not be started.");let f=l.origin;await new Promise((d,I)=>{let u=false,p=false,c=t=>{if(!p){if(p=true,window.clearInterval(A),window.clearTimeout(P),window.removeEventListener("message",h),n.close(),t){I(t);return}d();}},w=async()=>{if(u||p)return;u=true;let t;try{t=await o.pluginOAuthStatus(i.transactionId);}catch{u=false;return}if(u=false,t.status==="complete"){c();return}if(n.closed&&t.status==="pending"){c(new Error("Connection window was closed."));return}(t.status==="failed"||new Date(t.expires_at).getTime()<Date.now())&&c(new Error("Connection was not completed. Please try again."));},h=t=>{if(t.origin!==f||t.source!==n||!t.data||typeof t.data!="object")return;let a=t.data;if(a.type==="flexkit:plugin-oauth-ready"&&a.transactionId===i.transactionId){n.postMessage({type:"flexkit:plugin-oauth-start",transactionId:i.transactionId,ticket:i.launchTicket},f);return}if(a.type==="flexkit:plugin-oauth"&&a.transactionId===i.transactionId){if(a.status==="failed"&&a.error==="account_mismatch"){c(new g);return}w();}},A=window.setInterval(()=>{w();},2e3),P=window.setTimeout(()=>c(new Error("Connection timed out. Please try again.")),6e5);window.addEventListener("message",h),n.location.href=l.href;});}export{g as a,C as b};//# sourceMappingURL=chunk-KXAGLQ2B.js.map
2
- //# sourceMappingURL=chunk-KXAGLQ2B.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/apps/ai/plugin-oauth.ts"],"names":["OAUTH_START_PATH","PluginAccountMismatchError","httpsUrl","value","url","trustedPluginOAuthTargets","authorizeUrl","completionOrigin","origin","getPlatformOrigin","authorize","completion","connectPluginPopup","api","pluginId","scope","options","popup","transaction","error","targets","expectedOrigin","resolve","reject","polling","finished","finish","interval","timeout","onMessage","poll","status","event","payload"],"mappings":"wDAGA,IAAMA,CAAAA,CAAmB,uBAGZC,CAAAA,CAAN,cAAyC,KAAM,CAC3C,IAAA,CAAO,mBAEhB,WAAA,EAAc,CACZ,MAAM,kFAAkF,CAAA,CACxF,KAAK,IAAA,CAAO,6BACd,CACF,EAEA,SAASC,CAAAA,CAASC,CAAAA,CAA2B,CAC3C,IAAIC,EAEJ,GAAI,CACFA,EAAM,IAAI,GAAA,CAAID,CAAK,EACrB,CAAA,KAAQ,CACN,OAAO,IACT,CAEA,OAAIC,CAAAA,CAAI,QAAA,GAAa,UAAYA,CAAAA,CAAI,QAAA,GAAa,IAAMA,CAAAA,CAAI,QAAA,GAAa,EAAA,CAChE,IAAA,CAGFA,CACT,CAGA,SAASC,CAAAA,CACPC,CAAAA,CACAC,EACyC,CACzC,IAAMC,EAASC,CAAAA,EAAkB,CAC3BC,EAAYR,CAAAA,CAASI,CAAY,EACjCK,CAAAA,CAAaT,CAAAA,CAASK,CAAgB,CAAA,CAU5C,OARI,CAACG,CAAAA,EAAa,CAACC,CAAAA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GD,EAAM,WAAA,CACJ,CACE,KAAM,4BAAA,CACN,aAAA,CAAeC,EAAY,aAAA,CAC3B,MAAA,CAAQA,CAAAA,CAAY,YACtB,CAAA,CACAG,CACF,EAEA,MACF,CAEA,GAAIY,CAAAA,CAAQ,IAAA,GAAS,wBAA0BA,CAAAA,CAAQ,aAAA,GAAkBf,CAAAA,CAAY,aAAA,CAAe,CAClG,GAAIe,EAAQ,MAAA,GAAW,QAAA,EAAYA,EAAQ,KAAA,GAAU,kBAAA,CAAoB,CACvEP,CAAAA,CAAO,IAAIzB,CAA4B,CAAA,CAEvC,MACF,CAEK6B,IACP,CACF,EACMH,CAAAA,CAAW,MAAA,CAAO,YAAY,IAAM,CACnCG,CAAAA,GACP,CAAA,CAAG,GAAI,EACDF,CAAAA,CAAU,MAAA,CAAO,WAAW,IAAMF,CAAAA,CAAO,IAAI,KAAA,CAAM,yCAAyC,CAAC,CAAA,CAAG,GAAO,CAAA,CAC7G,OAAO,gBAAA,CAAiB,SAAA,CAAWG,CAAS,CAAA,CAC5CZ,CAAAA,CAAM,SAAS,IAAA,CAAOG,CAAAA,CAAQ,KAChC,CAAC,EACH","file":"chunk-KXAGLQ2B.js","sourcesContent":["import { getPlatformOrigin, type ApiClient } from './api';\nimport type { PluginScope } from './plugin-types';\n\nconst OAUTH_START_PATH = '/plugins/oauth/start';\n\n/** A Reconnect was completed with a different provider account than the one being reconnected. */\nexport class PluginAccountMismatchError extends Error {\n readonly code = 'account_mismatch';\n\n constructor() {\n super('You signed in with a different account. Use \"Connect another account\" to add it.');\n this.name = 'PluginAccountMismatchError';\n }\n}\n\nfunction httpsUrl(value: string): URL | null {\n let url: URL;\n\n try {\n url = new URL(value);\n } catch {\n return null;\n }\n\n if (url.protocol !== 'https:' || url.username !== '' || url.password !== '') {\n return null;\n }\n\n return url;\n}\n\n/** Popup navigation and postMessage stay on the platform OAuth start page. */\nfunction trustedPluginOAuthTargets(\n authorizeUrl: string,\n completionOrigin: string\n): { href: string; origin: string } | null {\n const origin = getPlatformOrigin();\n const authorize = httpsUrl(authorizeUrl);\n const completion = httpsUrl(completionOrigin);\n\n if (!authorize || !completion) {\n return null;\n }\n\n if (authorize.origin !== origin || authorize.pathname !== OAUTH_START_PATH) {\n return null;\n }\n\n if (completion.origin !== origin || completion.pathname !== '/') {\n return null;\n }\n\n return { href: authorize.href, origin };\n}\n\n/** Must be called directly from the click handler so browsers allow the popup. */\nexport async function connectPluginPopup(\n api: ApiClient,\n pluginId: string,\n scope: PluginScope,\n options?: { connectionId?: string }\n): Promise<void> {\n const popup = window.open('about:blank', `flexkit-plugin-${crypto.randomUUID()}`, 'popup,width=560,height=720');\n\n if (!popup) {\n throw new Error('Allow popups for Studio, then connect again.');\n }\n\n let transaction: Awaited<ReturnType<ApiClient['connectPlugins']>>;\n\n try {\n transaction = await api.connectPlugins({\n pluginId,\n scope,\n studioOrigin: window.location.origin,\n ...(options?.connectionId ? { connectionId: options.connectionId } : {}),\n });\n } catch (error) {\n popup.close();\n throw error;\n }\n\n const targets = trustedPluginOAuthTargets(transaction.authorizeUrl, transaction.completionOrigin);\n\n if (!targets) {\n popup.close();\n throw new Error('Connection could not be started.');\n }\n\n const expectedOrigin = targets.origin;\n\n await new Promise<void>((resolve, reject) => {\n let polling = false;\n let finished = false;\n const finish = (error?: Error) => {\n if (finished) {\n return;\n }\n\n finished = true;\n window.clearInterval(interval);\n window.clearTimeout(timeout);\n window.removeEventListener('message', onMessage);\n popup.close();\n\n if (error) {\n reject(error);\n\n return;\n }\n\n resolve();\n };\n const poll = async () => {\n if (polling || finished) {\n return;\n }\n\n polling = true;\n let status: Awaited<ReturnType<ApiClient['pluginOAuthStatus']>>;\n\n try {\n status = await api.pluginOAuthStatus(transaction.transactionId);\n } catch {\n polling = false;\n\n return;\n }\n\n polling = false;\n\n if (status.status === 'complete') {\n finish();\n\n return;\n }\n\n if (popup.closed && status.status === 'pending') {\n finish(new Error('Connection window was closed.'));\n\n return;\n }\n\n if (status.status === 'failed' || new Date(status.expires_at).getTime() < Date.now()) {\n finish(new Error('Connection was not completed. Please try again.'));\n }\n };\n const onMessage = (event: MessageEvent<unknown>) => {\n if (event.origin !== expectedOrigin || event.source !== popup || !event.data || typeof event.data !== 'object') {\n return;\n }\n\n const payload = event.data as { type?: string; transactionId?: string; status?: string; error?: string };\n\n if (payload.type === 'flexkit:plugin-oauth-ready' && payload.transactionId === transaction.transactionId) {\n popup.postMessage(\n {\n type: 'flexkit:plugin-oauth-start',\n transactionId: transaction.transactionId,\n ticket: transaction.launchTicket,\n },\n expectedOrigin\n );\n\n return;\n }\n\n if (payload.type === 'flexkit:plugin-oauth' && payload.transactionId === transaction.transactionId) {\n if (payload.status === 'failed' && payload.error === 'account_mismatch') {\n finish(new PluginAccountMismatchError());\n\n return;\n }\n\n void poll();\n }\n };\n const interval = window.setInterval(() => {\n void poll();\n }, 2000);\n const timeout = window.setTimeout(() => finish(new Error('Connection timed out. Please try again.')), 600_000);\n window.addEventListener('message', onMessage);\n popup.location.href = targets.href;\n });\n}\n"]}
@@ -1,2 +0,0 @@
1
- import'./index.css';import {q as q$1,o,r}from'./chunk-6YOVF2AD.js';import {f}from'./chunk-C47FNPLK.js';import {e}from'./chunk-TYDYAOQ7.js';import {useCallback}from'react';import {toast}from'sonner';import {useApolloClient}from'@apollo/client/react';function E(i){let{currentProjectSchema:t}=f();return useCallback(a=>{t&&q$1(o(i,t),a);},[i,t])}var g=["image/jpeg","image/png","image/webp","image/vnd.microsoft.icon","image/bmp","image/gif","image/tiff","image/svg+xml","image/avif","image/heic","image/heif","image/heic-sequence","image/heif-sequence","image/apng","audio/aac","audio/mpeg","audio/wav","audio/webm","audio/midi","audio/x-midi","audio/ogg","video/x-msvideo","video/mp4","video/mpeg","video/webm","video/quicktime","video/ogg","video/mp2t","video/3gpp","video/3gpp2","application/x-7z-compressed","application/zip","application/vnd.amazon.ebook","application/octet-stream","application/epub+zip","application/pdf","application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.ms-fontobject","application/gzip","application/x-gzip","application/java-archive","application/json","application/ld+json","text/javascript","application/vnd.oasis.opendocument.presentation","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.text","application/ogg","application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.rar","application/x-tar","application/vnd.visio","application/xhtml+xml","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/xml"];function F(i,t){if(!i.type)return true;let a=t?t.split(",").map(e=>e.trim()).filter(Boolean):g;return a.length===0?true:a.some(e=>e.endsWith("/*")?i.type.startsWith(e.slice(0,-1)):i.type===e)}async function x(i,t){let a=new URLSearchParams({filename:i.name}),e$1=await fetch(`${e(t).assets}?${a.toString()}`,{method:"POST",headers:{"Content-Type":i.type||"application/octet-stream"},body:i});if(!e$1.ok)throw new Error(`Upload failed for ${i.name}`);let n=await e$1.json(),o={_id:n._id,path:n.path??"",originalFilename:n.originalFilename??i.name,size:n.size??i.size,mimeType:n.mimeType??i.type,lqip:n.lqip??"",width:n.width??0,height:n.height??0};return {pathname:o.path,lqip:o.lqip||void 0,originalFilename:o.originalFilename,size:o.size,mimeType:o.mimeType,width:o.width||void 0,height:o.height||void 0,_id:o._id,asset:o}}async function h(i,t){let{projectId:a,accept:e,maxBytes:n=4*1024*1024,onUploadStart:o}=t,l=[];for(let p of Array.from(i)){if(p.size>n){toast.error(`File size too big (max ${(n/(1024*1024)).toFixed(0)}MB): ${p.name}`);continue}if(!F(p,e)){toast.error(`Unsupported file type: ${p.name}`);continue}l.push(p);}if(l.length===0)return [];o?.();try{let p=await Promise.all(l.map(async f=>x(f,a)));return p.length>0&&toast.success(`Uploaded ${p.length} file${p.length>1?"s":""}`),p}catch(p){return console.error(p),toast.error("Upload failed. Please try again."),[]}}async function b(i){let{accept:t,multiple:a=true}=i,e=document.createElement("input");e.type="file",e.accept=t??g.join(","),e.multiple=a,e.style.display="none",document.body.appendChild(e);try{let n=await new Promise(o=>{e.addEventListener("change",()=>o(e.files),{once:!0}),e.addEventListener("cancel",()=>o(null),{once:!0}),e.click();});return !n||n.length===0?[]:h(n,i)}finally{document.body.removeChild(e);}}function q(){let i=useApolloClient();return useCallback(async t=>{let a=t.files?await h(t.files,t):await b(t);return a.length>0&&await r(i,"GetAssets").catch(e=>{console.error("Error refreshing asset lists after upload:",e);}),a},[i])}export{E as a,x as b,q as c};//# sourceMappingURL=chunk-OFJOZMCR.js.map
2
- //# sourceMappingURL=chunk-OFJOZMCR.js.map
@@ -1,3 +0,0 @@
1
- import'./index.css';import {createContext,useContext}from'react';import $ from'swr';import {useParams,useHref}from'react-router-dom';import {jsx}from'react/jsx-runtime';var l="flexkit.io",S={"flexkit.io":true,"flexkit.test":true};function A(){let t=globalThis.process?.env?.FLEXKIT_DOMAIN?.trim();return t&&S[t]?t:l}var n=A();var p=n,f=`https://${p}`,a=t=>t?`https://${t}.api.${p}`:f,L=`${f}/images/`,i="-",m={authProviders:`/api/flexkit/${i}/auth/providers`,logout:`/api/flexkit/${i}/auth/logout`,me:`/api/flexkit/${i}/me`,notificationPreferences:`/api/flexkit/${i}/me/notification-preferences`,push:`/api/flexkit/${i}/me/push`,otpConfirm:`/api/flexkit/${i}/auth/otp/confirm`,otpSend:`/api/flexkit/${i}/auth/otp/send`};function u(t=""){return {assets:`/api/flexkit/${t}/assets`,authProviders:`/api/flexkit/${t}/auth/providers`,completion:`/api/flexkit/${t}/completion`,currentUser:`/api/flexkit/${t}/users/me`,loginOtpConfirm:`${a(t)}/auth/otp/confirm`,loginOtpSend:`${a(t)}/auth/otp/send`,logout:e=>{let o=new URLSearchParams({redirect:e});return `/api/flexkit/${t}/auth/logout?${o.toString()}`},schema:`/api/flexkit/${t}/schema`,search:`/api/flexkit/${t}/search`,sessionId:`${a(t)}/api/auth/login/session`}}async function h(t){try{await fetch(m.logout,{credentials:"same-origin",method:"POST"});}catch{}await fetch("/api/flexkit/logout",{credentials:"include",method:"GET"}),window.location.assign(t);}function c(t="projects"){let{projectId:e}=useParams(),o=useHref(`/${e??""}`),r=useHref("/"),{data:x,isLoading:k}=$(e?u(e).currentUser:null,P=>fetch(P,{mode:"cors",credentials:"include"}).then(s=>s.json()).then(s=>({...s,spaces:s.spaces??[]})));return [!!e&&k,{user:x,logout:async()=>{if(t==="hosted"){await h(r);return}await fetch(u(e??"").logout(o),{method:"POST",mode:"cors",credentials:"include"}),await fetch("/api/flexkit/logout",{method:"GET",credentials:"include"}),window.location.reload();}}]}var g=createContext([true,{user:null,logout:()=>Promise.resolve()}]);function B({children:t,mode:e="projects"}){let[o,r]=c(e);return jsx(g.Provider,{value:[o,r],children:t})}function J(){return useContext(g)}
2
- export{n as a,f as b,L as c,m as d,u as e,h as f,B as g,J as h};//# sourceMappingURL=chunk-TYDYAOQ7.js.map
3
- //# sourceMappingURL=chunk-TYDYAOQ7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/domains.ts","../src/core/api-paths.ts","../src/auth/hosted-logout.ts","../src/auth/use-auth-service.ts","../src/auth/auth-context.tsx"],"names":["defaultFlexkitDomain","allowedFlexkitDomains","getConfiguredFlexkitDomain","configuredDomain","flexkitDomain","domain","baseApiUrl","baseProjectApiUrl","projectId","IMAGES_BASE_URL","USER_API_SEGMENT","userApiPaths","apiPaths","redirectPath","params","signOutHosted","rootHref","useAuthService","mode","useParams","projectHref","useHref","user","isLoadingUser","useSWR","url","res","data","AuthContext","createContext","AuthProvider","children","isLoading","auth","jsx","useAuth","useContext"],"mappings":"yKAAA,IAAMA,CAAAA,CAAuB,aAEvBC,CAAAA,CAAoD,CACxD,aAAc,IAAA,CACd,cAAA,CAAgB,IAClB,CAAA,CAUA,SAASC,GAAqC,CAC5C,IAAMC,EAAoB,UAAA,CAAoC,OAAA,EAAS,KAAK,cAAA,EAAgB,IAAA,GAE5F,OAAKA,CAAAA,EAIDF,EAAsBE,CAAgB,CAAA,CACjCA,EAJAH,CAQX,KAEaI,CAAAA,CAAgBF,CAAAA,GC3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Q,SAAY,CAClB,GAAIJ,CAAAA,GAAS,QAAA,CAAU,CACrB,MAAMH,CAAAA,CAAcC,CAAQ,CAAA,CAE5B,MACF,CAGA,MAAM,KAAA,CAAMJ,EAASJ,CAAAA,EAAa,EAAE,EAAE,MAAA,CAAOY,CAAW,EAAG,CACzD,MAAA,CAAQ,OACR,IAAA,CAAM,MAAA,CACN,YAAa,SACf,CAAC,EAGD,MAAM,KAAA,CAAM,sBAAuB,CAAE,MAAA,CAAQ,MAAO,WAAA,CAAa,SAAU,CAAC,CAAA,CAE5E,MAAA,CAAO,SAAS,MAAA,GAClB,CACF,CACF,CACF,CCxCA,IAAMQ,CAAAA,CAAcC,aAAAA,CAAc,CAChC,IAAA,CACA,CACE,KAAM,IAAA,CACN,MAAA,CAAQ,IAAM,OAAA,CAAQ,OAAA,EACxB,CACF,CAAC,EAEM,SAASC,CAAAA,CAAa,CAC3B,QAAA,CAAAC,CAAAA,CACA,KAAAb,CAAAA,CAAO,UACT,EAGgB,CACd,GAAM,CAACc,CAAAA,CAAWC,CAAI,CAAA,CAAIhB,EAAeC,CAAI,CAAA,CAE7C,OAAOgB,GAAAA,CAACN,CAAAA,CAAY,SAAZ,CAAqB,KAAA,CAAO,CAACI,CAAAA,CAAWC,CAAI,EAAI,QAAA,CAAAF,CAAAA,CAAS,CACnE,CAEO,SAASI,GAAuB,CACrC,OAAOC,UAAAA,CAAWR,CAAW,CAC/B","file":"chunk-TYDYAOQ7.js","sourcesContent":["const defaultFlexkitDomain = 'flexkit.io';\n\nconst allowedFlexkitDomains: { [domain: string]: true } = {\n 'flexkit.io': true,\n 'flexkit.test': true,\n};\n\ntype GlobalWithProcessEnv = typeof globalThis & {\n process?: {\n env?: {\n [key: string]: string | undefined;\n };\n };\n};\n\nfunction getConfiguredFlexkitDomain(): string {\n const configuredDomain = (globalThis as GlobalWithProcessEnv).process?.env?.FLEXKIT_DOMAIN?.trim();\n\n if (!configuredDomain) {\n return defaultFlexkitDomain;\n }\n\n if (allowedFlexkitDomains[configuredDomain]) {\n return configuredDomain;\n }\n\n return defaultFlexkitDomain;\n}\n\nexport const flexkitDomain = getConfiguredFlexkitDomain();\nexport const flexkitApiDomain = `api.${flexkitDomain}`;\n","import { flexkitDomain } from './domains';\n\nconst domain = flexkitDomain;\nexport const baseApiUrl = `https://${domain}`;\nconst baseProjectApiUrl = (projectId?: string): string =>\n projectId ? `https://${projectId}.api.${domain}` : baseApiUrl;\n\ninterface ApiPaths {\n assets: string;\n authProviders: string;\n completion: string;\n currentUser: string;\n loginOtpConfirm: string;\n loginOtpSend: string;\n /** `redirectPath` is the absolute in-app path to return to after logout. */\n logout: (redirectPath: string) => string;\n /** Deployed project schema, scopes, spaces, title and menu groups. */\n schema: string;\n search: string;\n sessionId: string;\n}\n\nexport const IMAGES_BASE_URL = `${baseApiUrl}/images/`;\n\n/**\n * Reserved BFF segment for user-level (project-less) Flexkit API calls:\n * `/api/flexkit/-/me` is proxied to `https://<flexkitDomain>/api/me` with the\n * session as a bearer token. Project ids are ten characters, so `-` can never\n * collide with one.\n */\nexport const USER_API_SEGMENT = '-';\n\nexport const userApiPaths = {\n authProviders: `/api/flexkit/${USER_API_SEGMENT}/auth/providers`,\n logout: `/api/flexkit/${USER_API_SEGMENT}/auth/logout`,\n /** Signed-in user plus every project they can open. */\n me: `/api/flexkit/${USER_API_SEGMENT}/me`,\n /** The signed-in user's notification preferences (desktop kinds, approval email). */\n notificationPreferences: `/api/flexkit/${USER_API_SEGMENT}/me/notification-preferences`,\n /** Web Push: GET the VAPID public key, POST or DELETE this browser's subscription. */\n push: `/api/flexkit/${USER_API_SEGMENT}/me/push`,\n otpConfirm: `/api/flexkit/${USER_API_SEGMENT}/auth/otp/confirm`,\n otpSend: `/api/flexkit/${USER_API_SEGMENT}/auth/otp/send`,\n} as const;\n\nexport function apiPaths(projectId = ''): ApiPaths {\n return {\n assets: `/api/flexkit/${projectId}/assets`,\n authProviders: `/api/flexkit/${projectId}/auth/providers`,\n completion: `/api/flexkit/${projectId}/completion`,\n currentUser: `/api/flexkit/${projectId}/users/me`,\n loginOtpConfirm: `${baseProjectApiUrl(projectId)}/auth/otp/confirm`,\n loginOtpSend: `${baseProjectApiUrl(projectId)}/auth/otp/send`,\n logout: (redirectPath: string) => {\n const params = new URLSearchParams({ redirect: redirectPath });\n\n return `/api/flexkit/${projectId}/auth/logout?${params.toString()}`;\n },\n schema: `/api/flexkit/${projectId}/schema`,\n search: `/api/flexkit/${projectId}/search`,\n sessionId: `${baseProjectApiUrl(projectId)}/api/auth/login/session`,\n };\n}\n","import { userApiPaths } from '../core/api-paths';\n\n/** Hosted mode sign-out: end the Flexkit session, drop the first-party cookie, go back to the Studio root. */\nexport async function signOutHosted(rootHref: string): Promise<void> {\n try {\n await fetch(userApiPaths.logout, { credentials: 'same-origin', method: 'POST' });\n } catch {\n // The cookie is cleared below either way; the session expires server-side.\n }\n\n await fetch('/api/flexkit/logout', { credentials: 'include', method: 'GET' });\n window.location.assign(rootHref);\n}\n","'use client';\n\nimport useSWR from 'swr';\nimport { useHref, useParams } from 'react-router-dom';\nimport { apiPaths } from '../core/api-paths';\nimport type { StudioMode } from '../core/config/types';\nimport { signOutHosted } from './hosted-logout';\nimport type { AuthService, User } from './types';\n\nexport default function useAuthService(mode: StudioMode = 'projects'): AuthService {\n const { projectId } = useParams();\n // Absolute path of the current project under the router basename.\n const projectHref = useHref(`/${projectId ?? ''}`);\n const rootHref = useHref('/');\n // Role and spaces are per project, so there is nothing to ask until a project is open.\n const { data: user, isLoading: isLoadingUser } = useSWR(projectId ? apiPaths(projectId).currentUser : null, (url: string) =>\n fetch(url, { mode: 'cors', credentials: 'include' })\n .then((res) => res.json() as Promise<User>)\n .then((data) => ({ ...data, spaces: data.spaces ?? [] }))\n );\n const isLoading = Boolean(projectId) && isLoadingUser;\n\n return [\n isLoading,\n {\n user,\n logout: async () => {\n if (mode === 'hosted') {\n await signOutHosted(rootHref);\n\n return;\n }\n\n // wipe remote session\n await fetch(apiPaths(projectId ?? '').logout(projectHref), {\n method: 'POST',\n mode: 'cors',\n credentials: 'include',\n });\n\n // delete first-party auth cookie\n await fetch('/api/flexkit/logout', { method: 'GET', credentials: 'include' });\n\n window.location.reload();\n },\n },\n ];\n}\n","'use client';\n\nimport { createContext, JSX, useContext } from 'react';\nimport useAuthService from './use-auth-service';\nimport type { Auth, AuthService, User } from './types';\nimport type { StudioMode } from '../core/config/types';\n\nconst AuthContext = createContext([\n true,\n {\n user: null as User | null,\n logout: () => Promise.resolve(),\n } as Auth,\n]);\n\nexport function AuthProvider({\n children,\n mode = 'projects',\n}: {\n children: React.ReactNode;\n mode?: StudioMode;\n}): JSX.Element {\n const [isLoading, auth] = useAuthService(mode);\n\n return <AuthContext.Provider value={[isLoading, auth]}>{children}</AuthContext.Provider>;\n}\n\nexport function useAuth(): AuthService {\n return useContext(AuthContext) as AuthService;\n}\n"]}
@@ -1,2 +0,0 @@
1
- import'./index.css';import {h}from'./chunk-TYDYAOQ7.js';function n(e){return e?e!=="viewer":true}function r(){let[,e]=h();return n(e.user?.role)}export{n as a,r as b};//# sourceMappingURL=chunk-V64P56OA.js.map
2
- //# sourceMappingURL=chunk-V64P56OA.js.map
@@ -1,2 +0,0 @@
1
- import'./index.css';import {c as c$2,a}from'./chunk-EWBEPYML.js';import {s,m as m$1,J,d,u,v,w,x}from'./chunk-6YOVF2AD.js';import {c}from'./chunk-P6BZ4QP7.js';import'./chunk-V64P56OA.js';import'./chunk-2DXR5NJV.js';import {f}from'./chunk-C47FNPLK.js';import'./chunk-TYDYAOQ7.js';import {N}from'./chunk-YCCFUGWJ.js';import {v as v$1}from'./chunk-32ZU4MLE.js';import'./chunk-HDOIOXMP.js';import {t}from'./chunk-SZEGGBOC.js';import'./chunk-U45E5X3H.js';import {b,c as c$1,e}from'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useMemo,useCallback}from'react';import {useParams,useLocation,Outlet}from'react-router-dom';import {jsx,jsxs}from'react/jsx-runtime';var m=36,ct=[{_updatedAt:"DESC"},{_id:"DESC"}];function vt(){let{entity:t}=useParams(),{search:a}=useLocation(),g=new URLSearchParams(a).get("id"),{scope:j}=c(),{schemaErrorMessage:G}=s(),{currentProject:Q}=f(),h=Q?.schema??[],n=m$1(h,t??""),[r,S]=useState([]),[W,B]=useState(0),[O,F]=useState(t);t!==O&&(F(t),S([]));let k=J({attributesSchema:n?.attributes??[],actionsComponent:o=>ut({entityName:n?.name??"",entityNamePlural:t??"",row:o}),checkboxSelect:"multiple",enableColumnSorting:true}),f$1=useMemo(()=>{if(r.length===0)return ct;let o=r.map(({id:u,desc:it})=>({[u]:it?"DESC":"ASC"}));return o.some(u=>"_id"in u)?o:[...o,{_id:"DESC"}]},[r]),y=useMemo(()=>{if(r.length!==0)return d(f$1,n)},[n,f$1,r.length]),H=g?{where:{_id:{eq:g}}}:{offset:0,limit:m,sort:f$1,...y?{where:y}:{}},{isLoading:Y,isLoadingMore:Z,fetchMore:b$1,reload:C,count:i,data:l,isProjectDisabled:$}=u({entityNamePlural:t??"",schema:h,scope:j,variables:H,selection:"list"});function tt(o){S(o);}let N$1=l?.length??0,et=i>0&&N$1>0&&N$1<i,ot=useCallback(()=>{b$1({variables:{offset:0,limit:m}});},[b$1]),nt=useCallback(()=>{B(o=>o+1),C();},[C]),rt=Array(m).fill({}),at=pt(k),s$1=Y&&(l==null||l.length===0);return $?jsx("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3",children:jsx(v,{})}):jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:px-4 fk:pt-3",children:[jsx(w,{}),jsxs("div",{className:"fk:flex fk:items-center fk:mb-4 fk:gap-2",children:[jsxs(b,{children:[jsx(c$1,{asChild:true,children:jsx(N,{className:"fk:-ml-1 fk:w-4 fk:h-4"})}),jsx(e,{children:"Toggle Sidebar"})]}),jsx(v$1,{orientation:"vertical",className:"fk:h-4"}),jsx("h2",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:ft(n?.menu?.label??n?.plural??"")}),s$1?null:jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[i.toLocaleString()," ",i===1?"record":"records"]})]}),G?null:jsx(x,{columns:s$1?at:k,data:s$1?rt:l??[],entityName:n?.name??"",hasMore:et,isLoadingMore:Z,pageSize:m,scrollToTopKey:W,sorting:r,onLoadMore:ot,onSortingChange:tt,toolbarComponent:o=>jsx(c$2,{entityName:n?.name??"",isReloading:s$1,onReload:nt,table:o})}),jsx(Outlet,{})]})}function ft(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ut({entityName:t,entityNamePlural:a$1,row:d}){return jsx(a,{entityName:t,entityNamePlural:a$1,row:d})}function pt(t$1){return t$1.map(a=>({...a,cell:()=>jsx(t,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}export{vt as List};//# sourceMappingURL=list-DOTORSUC.js.map
2
- //# sourceMappingURL=list-DOTORSUC.js.map
@@ -1,2 +0,0 @@
1
- import'./index.css';export{b as CatalogHeader,d as InstalledPluginsPage,a as PluginConnectControl,e as PluginDetailPage,c as PluginsPage}from'./chunk-BOXFB6E6.js';import'./chunk-KXAGLQ2B.js';import'./chunk-2HSIWUH3.js';import'./chunk-C47FNPLK.js';import'./chunk-TYDYAOQ7.js';import'./chunk-YCCFUGWJ.js';import'./chunk-32ZU4MLE.js';import'./chunk-HDOIOXMP.js';import'./chunk-SZEGGBOC.js';import'./chunk-U45E5X3H.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';//# sourceMappingURL=plugin-pages-RKJRHKNL.js.map
2
- //# sourceMappingURL=plugin-pages-RKJRHKNL.js.map
@@ -1,2 +0,0 @@
1
- import'./index.css';import {a}from'./chunk-HYSTMQD7.js';import {b,c}from'./chunk-F2DHCPWW.js';import'./chunk-QQSI7BPK.js';import'./chunk-KXAGLQ2B.js';import {g,f as f$1}from'./chunk-2HSIWUH3.js';import {f}from'./chunk-C47FNPLK.js';import'./chunk-TYDYAOQ7.js';import {L,P,M,R,T as T$1,s as s$1,Q,U as U$1,V,W,O}from'./chunk-YCCFUGWJ.js';import {b as b$1}from'./chunk-32ZU4MLE.js';import'./chunk-HDOIOXMP.js';import'./chunk-SZEGGBOC.js';import'./chunk-U45E5X3H.js';import'./chunk-USNXQOMJ.js';import'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {Outlet,useLocation,NavLink}from'react-router-dom';import {useState}from'react';import {SearchIcon,XIcon,SquarePenIcon,BellIcon,BotIcon,HistoryIcon,InboxIcon,PlugIcon}from'lucide-react';import Q$1 from'swr';import {jsxs,jsx}from'react/jsx-runtime';var K=300,s=NavLink;function T(){let{currentProjectId:a}=f(),{data:e}=Q$1(a?g(a).approvalsCount:null,f$1,{refreshInterval:3e4}),o=e?.pendingCount??0;return o===0?null:jsx(b$1,{className:"fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:bg-amber-500/20 fk:px-1.5 fk:text-[0.6875rem] fk:text-amber-600 fk:border-none fk:corner-squircle",children:o>99?"99+":o.toString()})}function U(){let{currentProjectId:a$1}=f(),e=a(a$1),o=e?.needsActionCount??0,f$1=o>0?o:e?.unreadCount??0;return f$1===0?null:jsx(b$1,{className:`fk:ml-auto fk:h-5 fk:min-w-5 fk:justify-center fk:rounded-full fk:px-1.5 fk:text-[0.6875rem] fk:border-none fk:corner-squircle ${o>0?"fk:bg-amber-500/20 fk:text-amber-600":"fk:bg-muted fk:text-muted-foreground"}`,children:f$1>99?"99+":f$1.toString()})}function B(){let e=useLocation().pathname.replace(/\/$/,""),o=e.endsWith("/ai/agent"),f=e.endsWith("/ai/runs"),w=e.endsWith("/ai/approvals"),P=e.endsWith("/ai/activity")||e.includes("/ai/activity/"),R$1=e.includes("/ai/plugins")||e.includes("/ai/skills"),W$1=e.includes("/ai/automations"),[d,k]=useState(""),E=b(d.trim(),K);return jsxs(M,{collapsible:"icon",variant:"inset",children:[jsx(R,{className:"fk:shrink-0 fk:pb-1.5 fk:group-data-[collapsible=icon]:hidden",children:jsxs(T$1,{className:"fk:relative",children:[jsx(SearchIcon,{className:"fk:absolute fk:left-2 fk:top-1/2 fk:size-3.5 fk:-translate-y-1/2 fk:text-muted-foreground"}),jsx(s$1,{className:"fk:h-8 fk:bg-background fk:pl-7 fk:pr-7 fk:text-sm",placeholder:"Search chats...",value:d,onChange:L=>k(L.target.value)}),d?jsx("button",{"aria-label":"Clear search",className:"fk:absolute fk:right-2 fk:top-1/2 fk:-translate-y-1/2 fk:cursor-pointer fk:text-muted-foreground fk:hover:text-foreground",type:"button",onClick:()=>k(""),children:jsx(XIcon,{className:"fk:size-3.5"})}):null]})}),jsxs(Q,{children:[jsx(R,{children:jsxs(U$1,{children:[jsx(V,{children:jsx(W,{asChild:true,isActive:o,tooltip:"New chat",children:jsxs(s,{to:"agent",children:[jsx(SquarePenIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"New chat"})]})})}),jsx(V,{children:jsx(W,{asChild:true,isActive:P,tooltip:"Activity",children:jsxs(s,{to:"activity",children:[jsx(BellIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Activity"}),jsx(U,{})]})})}),jsx(V,{children:jsx(W,{asChild:true,isActive:W$1,tooltip:"Automations",children:jsxs(s,{to:"automations",children:[jsx(BotIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Automations"})]})})}),jsx(V,{children:jsx(W,{asChild:true,isActive:f,tooltip:"Run History",children:jsxs(s,{to:"runs",children:[jsx(HistoryIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Run History"})]})})}),jsx(V,{children:jsx(W,{asChild:true,isActive:w,tooltip:"Approvals",children:jsxs(s,{to:"approvals",children:[jsx(InboxIcon,{className:"fk:h-4 fk:w-4",strokeWidth:2}),jsx("span",{children:"Approvals"}),jsx(T,{})]})})}),jsx(V,{children:jsx(W,{asChild:true,isActive:R$1,tooltip:"Plugins",children:jsxs(s,{to:"plugins",children:[jsx(PlugIcon,{className:"fk:size-4"}),jsx("span",{children:"Plugins"})]})})})]})}),jsx(R,{className:"fk:mt-4 fk:group-data-[collapsible=icon]:hidden",children:jsx(T$1,{children:jsx(c,{query:E})})})]}),jsx(O,{})]})}var F="flexkit:sidebar:state";function pt(){let{currentProjectId:a}=f(),e=document.cookie.split("; ").find(o=>o.startsWith(`${F}=`))?.split("=")[1]!=="false";return a?jsxs(L,{className:"fk:h-full",defaultOpen:e,children:[jsx(B,{}),jsx(P,{className:"fk:min-w-0",children:jsx("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:min-w-0 fk:flex-col fk:overflow-hidden fk:pl-4 fk:pt-3",children:jsx("div",{className:"fk:flex fk:min-h-0 fk:min-w-0 fk:flex-1 fk:flex-col",children:jsx(Outlet,{})})})})]}):jsx("main",{className:"fk:flex fk:h-full fk:flex-1 fk:items-center fk:justify-center fk:p-8 fk:text-sm fk:text-muted-foreground",children:"Select a project to manage automations and skills."})}export{pt as Root};//# sourceMappingURL=root-76YQTZUI.js.map
2
- //# sourceMappingURL=root-76YQTZUI.js.map
@@ -1,23 +0,0 @@
1
- import'./index.css';import {c as c$3,a as a$3}from'./chunk-OFJOZMCR.js';import {a as a$1}from'./chunk-7IHEL6LU.js';import {a as a$2}from'./chunk-3C2EG3SI.js';import {s,J,u,v,w,x as x$1,C,j,e,h,g,A,B,E,G,F,H}from'./chunk-6YOVF2AD.js';import {c}from'./chunk-P6BZ4QP7.js';import {b as b$1}from'./chunk-V64P56OA.js';import'./chunk-2DXR5NJV.js';import {f,b}from'./chunk-C47FNPLK.js';import'./chunk-TYDYAOQ7.js';import {x,y,z,s as s$1,ma,c as c$4,d as d$1,o as o$2}from'./chunk-YCCFUGWJ.js';import {c as c$2,d,h as h$1,i,k,l,j as j$1,w as w$1,n,o as o$1,p,q,r,t as t$1,s as s$2}from'./chunk-32ZU4MLE.js';import'./chunk-HDOIOXMP.js';import {e as e$2,g as g$1,h as h$2,j as j$2,o,t}from'./chunk-SZEGGBOC.js';import'./chunk-U45E5X3H.js';import {a,b as b$2,c as c$1,e as e$1}from'./chunk-USNXQOMJ.js';import {b as b$3}from'./chunk-6NRQMG26.js';import'./chunk-O2QMYUPS.js';import {useState,useMemo,useCallback,useRef,useEffect}from'react';import {TagIcon,PlusIcon,Loader2,Ellipsis,Check,Copy,Link,MinusIcon,Trash2,LoaderCircle,Search,X,ImagePlayIcon,ImageIcon,FilePlayIcon,LayersIcon,SplinePointerIcon,ListChecks,Trash2Icon,LayoutGrid,List}from'lucide-react';import {gql}from'@apollo/client';import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useLocation,Outlet,useParams}from'react-router-dom';import {useReactTable,getSortedRowModel,getPaginationRowModel,getFilteredRowModel,getCoreRowModel}from'@tanstack/react-table';import {defaultStyles,FileIcon}from'react-file-icon';var we={where:{},limit:500,offset:0,sort:[{name:"ASC"}]},Y={selection:"display",includeCount:false};function Et(){let{scope:e$3}=c(),{currentProjectSchema:n}=f(),[t,a$1,i$1]=C(),[f$1,c$3]=useState(""),[d$1,b]=useState(false),[v,u$1]=useState(false),[l$1,s]=useState(null),[M,p]=useState(false),[E,I]=useState(null),[J,x]=useState(""),[_,U]=useState(false),[F,B]=useState(false),h$3=b$1(),D="_tag",m="_tags",{data:C$1,isLoading:S}=u({entityNamePlural:m,schema:n,scope:e$3,variables:we,...Y}),z=(Array.isArray(C$1)?C$1:[]).map(r=>{let V=r;return {_id:V._id,name:V.name}}),O=useCallback(async()=>{let r=f$1.trim();if(!r)return;U(true);let V=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}`,L=j(m,n,{name:{value:r,disabled:false,scope:"default"}},V),j$1=e(m,e$3,n,Y),K=gql`
2
- ${j$1.query}
3
- `;await new Promise(y=>{a$1(gql`
4
- ${L}
5
- `),i$1({refetchQueries:[K],onCompleted:()=>{c$3(""),b(false),y();}}),t(true);}),U(false);},[m,t,n,e$3,a$1,i$1,f$1]),w=useCallback(async r=>{B(true);let V=h(D,n,r),X=e(m,e$3,n,Y),L=gql`
6
- ${X.query}
7
- `;await new Promise((j,K)=>{a$1(gql`
8
- ${V}
9
- `),i$1({variables:{where:{_id:{eq:r}}},refetchQueries:[L],onCompleted:()=>{j();},onError:y=>{K(y);}}),t(true);}),B(false);},[D,m,t,n,e$3,a$1,i$1]),P=useCallback(async()=>{let r=J.trim();if(!r||!E)return;U(true);let V={name:{value:r,disabled:false,scope:"default"}},X={},L=g(m,E._id,e$3,n,X,V),j=e(m,e$3,n,Y),K=gql`
10
- ${j.query}
11
- `;await new Promise(y=>{a$1(gql`
12
- ${L}
13
- `),i$1({variables:{where:{_id:{eq:E._id}}},refetchQueries:[K],onCompleted:()=>{p(false),I(null),x(""),y();}}),t(true);}),U(false);},[J,m,t,n,e$3,a$1,i$1,E]);return jsxs("div",{className:"fk:flex fk:h-full fk:max-h-screen fk:flex-col fk:gap-2",children:[jsxs("div",{className:"fk:flex fk:h-12 fk:items-center fk:border-b fk:border-b-border fk:px-4 fk:lg:px-6",children:[jsx(TagIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:px-4 fk:text-sm fk:font-semibold fk:tracking-tight",children:"Tags"}),h$3?jsx(a,{children:jsxs(b$2,{children:[jsx(c$1,{asChild:true,children:jsxs(c$2,{open:d$1,onOpenChange:b,children:[jsx(d,{asChild:true,children:jsxs(b$3,{variant:"secondary",size:"icon",className:"fk:ml-auto fk:h-8 fk:w-8",children:[jsx(PlusIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Add tag"})]})}),jsxs(h$1,{children:[jsxs(i,{children:[jsx(k,{children:"New tag"}),jsx(l,{className:"fk:sr-only",children:"Create a new tag"})]}),jsx("div",{className:"fk:flex fk:gap-2",children:jsx(s$1,{autoFocus:true,value:f$1,placeholder:"New tag name",onChange:r=>c$3(r.target.value),onKeyDown:r=>{r.key==="Enter"&&O();}})}),jsx(j$1,{children:jsxs(b$3,{disabled:_,onClick:O,variant:"default",children:[_?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Add"]})})]})]})}),jsx(e$1,{children:jsx("p",{children:"Add tag"})})]})}):jsx("div",{className:"fk:ml-auto",children:jsx(ma,{disabled:true,children:jsxs(b$3,{disabled:true,variant:"secondary",size:"icon",className:"fk:h-8 fk:w-8",children:[jsx(PlusIcon,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Add tag"})]})})})]}),jsx(w$1,{className:"fk:h-full",children:jsx("div",{className:"fk:flex fk:flex-col fk:gap-2 fk:px-4 fk:py-2",children:S?jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:"Loading..."}):z.length===0?jsx("div",{className:"fk:text-sm fk:text-muted-foreground",children:"No tags yet"}):z.map(r=>jsxs("div",{className:"fk:group fk:flex fk:items-center fk:justify-between fk:rounded-sm fk:border fk:border-border fk:bg-card fk:px-3 fk:py-1 fk:corner-squircle",children:[jsx("span",{className:"fk:text-sm",children:r.name}),jsxs(e$2,{children:[jsx(ma,{disabled:!h$3,children:jsx(g$1,{asChild:true,children:jsx(b$3,{"aria-label":`Actions for ${r.name}`,disabled:!h$3,title:h$3?`Actions for ${r.name}`:void 0,variant:"ghost",size:"icon",className:"fk:h-7 fk:w-7 fk:text-muted-foreground fk:hover:text-foreground",children:jsx(Ellipsis,{className:"fk:h-4 fk:w-4"})})})}),jsxs(h$2,{align:"end",className:"w-[160px]",children:[jsx(j$2,{onClick:()=>{I(r),x(r.name),p(true);},children:"Edit"}),jsx(o,{}),jsx(j$2,{className:"fk:text-destructive",onClick:()=>{s(r),u$1(true);},children:"Remove"})]})]})]},r._id))})}),jsx(c$2,{open:M,onOpenChange:p,children:jsxs(h$1,{children:[jsxs(i,{children:[jsx(k,{children:"Edit tag"}),jsx(l,{className:"fk:sr-only",children:"Rename an existing tag"})]}),jsx("div",{className:"fk:flex fk:gap-2",children:jsx(s$1,{autoFocus:true,value:J,placeholder:"Tag name",onChange:r=>x(r.target.value),onKeyDown:r=>{r.key==="Enter"&&P();}})}),jsxs(j$1,{children:[jsx(b$3,{disabled:_,variant:"secondary",onClick:()=>{p(false),I(null);},children:"Cancel"}),jsxs(b$3,{disabled:_,onClick:P,variant:"default",children:[_?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Save"]})]})]})}),jsx(c$2,{open:v,onOpenChange:u$1,children:jsxs(h$1,{children:[jsxs(i,{children:[jsx(k,{children:"Delete tag"}),jsx(l,{className:"fk:sr-only",children:"Confirm deletion of a tag"})]}),jsxs("div",{className:"fk:text-sm fk:text-muted-foreground",children:["Are you sure you want to delete the tag"," ",jsx("span",{className:"fk:font-semibold fk:text-foreground",children:l$1?.name}),"?"]}),jsxs(j$1,{children:[jsx(b$3,{disabled:F,variant:"secondary",onClick:()=>{u$1(false),s(null);},children:"Cancel"}),jsxs(b$3,{disabled:F,variant:"destructive",onClick:()=>{l$1&&(async()=>(await w(l$1._id),u$1(false),s(null)))();},children:[F?jsx(Loader2,{className:"fk:h-4 fk:w-4 fk:mr-2 fk:animate-spin"}):null,"Delete"]})]})]})})]})}function Fe(e){return Array.from(e.dataTransfer.types).includes("Files")}function _t({children:e,disabled:n=false,onDropFiles:t}){let a=useRef(0),[i,f]=useState(false);function c(){a.current=0,f(false);}function d(l){Fe(l)&&(l.preventDefault(),l.stopPropagation(),a.current+=1,n||f(true));}function b(l){Fe(l)&&(l.preventDefault(),l.stopPropagation(),l.dataTransfer.dropEffect=n?"none":"copy");}function v(l){Fe(l)&&(l.preventDefault(),l.stopPropagation(),a.current=Math.max(0,a.current-1),a.current===0&&f(false));}function u(l){if(!Fe(l)||(l.preventDefault(),l.stopPropagation(),c(),n))return;let s=Array.from(l.dataTransfer.files);s.length!==0&&t(s);}return jsxs("div",{className:"fk:relative fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",onDragEnter:d,onDragLeave:v,onDragOver:b,onDrop:u,children:[jsx("div",{className:"fk:flex fk:min-h-0 fk:flex-1 fk:flex-col",children:e}),i?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:inset-0 fk:z-30 fk:flex fk:items-center fk:justify-center fk:rounded-md fk:border-2 fk:border-dashed fk:border-primary fk:bg-background/80 fk:corner-squircle",children:jsx("p",{className:"fk:text-sm fk:font-medium fk:text-foreground",children:"Drop files to upload"})}):null]})}var Ft=`_updatedAt
14
- tags(limit: 3, offset: 0) {
15
- _id
16
- name
17
- }
18
- `;function Ve({assetIds:e,mode:n$1,onModeChange:t,onCompleted:a}){let{scope:i}=c(),f$1=a$3("_assets"),[c$1,d,b]=C(),{currentProjectSchema:v}=f(),[u$1,l]=useState([]),[s,M]=useState(false),{data:p$1}=u({entityNamePlural:"_tags",schema:v,scope:i,variables:we,...Y}),E=useMemo(()=>(Array.isArray(p$1)?p$1:[]).map(D=>({_id:D._id,name:D.name})),[p$1]),I=useCallback(()=>{l([]);},[]),J=useCallback(h=>{!h&&!s&&(t(null),I());},[s,t,I]),x=useCallback(h=>{let m=(h?.update_assets?._assets??[]).filter(C=>typeof C?._id=="string").map(C=>{let S=(Array.isArray(C.tags)?C.tags:[]).map(z=>z.name).filter(Boolean).slice(0,3).join(", ");return {_id:C._id,attributes:{tags:S,...typeof C._updatedAt=="string"?{_updatedAt:C._updatedAt}:{}}}});m.length>0&&f$1(m);},[f$1]),_=useCallback(async()=>{if(!(e.length===0||u$1.length===0||s)){M(true);try{let h={tags:{relationships:{connect:u$1.map(m=>({_id:m}))},disabled:!1,scope:i}},D=g("_assets",e[0]??"",i,v,{},h,{responseFields:Ft});await new Promise((m,C)=>{d(gql`
19
- ${D}
20
- `),b({variables:{where:{_id:{in:e}}},onCompleted:S=>{x(S),m();},onError:S=>C(S)}),c$1(!0);}),a?.(),I(),t(null);}catch{}finally{M(false);}}},[x,e,s,a,t,I,c$1,v,i,u$1,d,b]),U=useCallback(async()=>{if(!(e.length===0||u$1.length===0||s)){M(true);try{let h={tags:{relationships:{disconnect:u$1},disabled:!1,scope:i}},D=g("_assets",e[0]??"",i,v,{},h,{responseFields:Ft});await new Promise((m,C)=>{d(gql`
21
- ${D}
22
- `),b({variables:{where:{_id:{in:e}}},onCompleted:S=>{x(S),m();},onError:S=>C(S)}),c$1(!0);}),a?.(),I(),t(null);}catch{}finally{M(false);}}},[x,e,s,a,t,I,c$1,v,i,u$1,d,b]),F=n$1==="remove",B=F?"Remove tag(s)":"Add tag(s)";return e.length>1&&(B=F?"Remove tag(s) from selected assets":"Add tag(s) to selected assets"),jsxs(n,{open:n$1!==null,onOpenChange:J,children:[jsx(o$1,{placeholder:"Search tags..."}),jsxs(p,{className:"fk:h-75",children:[jsx(q,{children:"No tags found."}),jsx(r,{heading:"Tags",children:E.map(h=>{let D=u$1.includes(h._id);return jsxs(t$1,{disabled:s,onSelect:()=>{s||l(m=>D?m.filter(C=>C!==h._id):[...m,h._id]);},children:[jsx("input",{className:"fk:mr-2",checked:D,onChange:()=>{},type:"checkbox"}),h.name]},h._id)})})]}),jsx(s$2,{}),jsx("div",{className:"fk:p-2",children:jsxs(b$3,{className:"fk:w-full",disabled:u$1.length===0||s,onClick:F?U:_,children:[s?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,B]})})]})}function qe({overlay:e=false,row:n}){let[t,a]=useState(null),[i,f]=useState(null),c=A(),d=b$1(),b$2=n.original,v=b$2._id??"",u=b$2.url??"";function l(){c({type:"DeleteEntity",payload:{entityId:v,entityName:b.name}});}function s(p,E){navigator.clipboard.writeText(E),a(p),window.setTimeout(()=>a(null),1500);}return jsxs(Fragment,{children:[jsxs(e$2,{children:[jsx(g$1,{asChild:true,children:jsxs(b$3,{className:e?"fk:flex fk:h-7 fk:w-7 fk:p-0 fk:text-white fk:group-hover:bg-background/10 fk:group-hover:text-white! fk:data-[state=open]:bg-background/15":"fk:flex fk:h-8 fk:w-8 fk:p-0 fk:data-[state=open]:bg-muted",onClick:p=>p.stopPropagation(),variant:"ghost",children:[jsx(Ellipsis,{className:"fk:h-4 fk:w-4"}),jsx("span",{className:"fk:sr-only",children:"Open menu"})]})}),jsxs(h$2,{align:"start",className:"fk:w-45",children:[jsxs(j$2,{disabled:!v,onClick:p=>{p.stopPropagation(),s("id",v);},children:[t==="id"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Copy,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy ID"]}),jsxs(j$2,{disabled:!u,onClick:p=>{p.stopPropagation(),s("url",u);},children:[t==="url"?jsx(Check,{className:"fk:mr-2 fk:h-4 fk:w-4"}):jsx(Link,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Copy URL"]}),jsx(o,{}),jsxs(j$2,{disabled:!v||!d,onClick:p=>{p.stopPropagation(),f("add");},children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Add tag"]}),jsxs(j$2,{disabled:!v||!d,onClick:p=>{p.stopPropagation(),f("remove");},children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Remove tag"]}),jsx(o,{}),jsxs(j$2,{className:"fk:text-destructive",disabled:!v||!d,onClick:p=>{p.stopPropagation(),l();},children:[jsx(Trash2,{className:"fk:mr-2 fk:h-4 fk:w-4"}),"Delete"]})]})]}),i!==null?jsx(Ve,{assetIds:v?[v]:[],mode:i,onModeChange:f}):null]})}var bo=FileIcon,wo="fk:bg-[#fafafa] [--asset-checker:#f0f0f0] [background-image:linear-gradient(45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(-45deg,var(--asset-checker)_25%,transparent_25%),linear-gradient(45deg,transparent_75%,var(--asset-checker)_75%),linear-gradient(-45deg,transparent_75%,var(--asset-checker)_75%)] [background-position:0_0,0_4px,4px_-4px,-4px_0px] [background-size:8px_8px] fk:dark:bg-[#222] dark:[--asset-checker:#2a2a2a]";function Do(e){return Math.max(600,e)}function Co(e){return e==null||Number.isNaN(e)?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ot({columns:e,data:n,entityName:t$1,hasMore:a=false,isLoading:i=false,isLoadingMore:f=false,onLoadMore:c,onSortingChange:d,pageSize:b,sorting:v,toolbarComponent:u}){let l=useRef(null),{schemaErrorMessage:s$1}=s(),[M,p]=useState({}),[E,I]=useState({}),[J,x]=useState([]),[_,U]=useState([]),F=v??_;useEffect(()=>{l.current?.scrollTo({top:0});},[t$1]);function B(w){if(d){d(w);return}U(w);}let h=useReactTable({data:n,columns:e,state:{sorting:F,columnVisibility:E,rowSelection:M,columnFilters:J},initialState:{pagination:{pageSize:b??50}},enableRowSelection:true,onRowSelectionChange:p,onSortingChange:B,onColumnFiltersChange:x,onColumnVisibilityChange:I,getCoreRowModel:getCoreRowModel(),getFilteredRowModel:getFilteredRowModel(),getPaginationRowModel:getPaginationRowModel(),getSortedRowModel:getSortedRowModel(),getRowId:w=>w._id,manualFiltering:true,manualPagination:true,manualSorting:true}),{rows:D}=h.getRowModel(),m=useRef(c),C=useRef(a),S=useRef(f);m.current=c,C.current=a,S.current=f;let z=useCallback(w=>{if(!m.current||!C.current||S.current)return;let P=w??l.current;if(!P)return;let{scrollHeight:r,scrollTop:V,clientHeight:X}=P;r-V-X>=Do(X)||m.current();},[]);useEffect(()=>{z();},[z,D.length,a,f]);function O(w){z(w.currentTarget);}return s$1?jsx(Fragment,{}):jsxs("div",{className:"fk:flex fk:h-full fk:min-h-0 fk:w-full fk:min-w-0 fk:flex-col fk:gap-4",children:[u?u(h):null,jsxs("div",{className:"fk:relative fk:min-h-0 fk:min-w-0 fk:flex-1",children:[f?jsx("div",{"aria-hidden":true,className:"fk:pointer-events-none fk:absolute fk:top-0 fk:right-px fk:left-px fk:z-20 fk:h-0.5 fk:overflow-hidden fk:opacity-40",children:jsx("div",{className:"fk:animate-progress fk:h-full fk:w-full fk:bg-foreground"})}):null,jsxs("div",{className:"fk:h-full fk:overflow-auto fk:pt-px fk:pb-20 fk:-ml-0.5 fk:pr-3",onScroll:O,ref:l,children:[i?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:gap-3",children:Array.from({length:b??50},(w,P)=>jsxs("div",{className:"fk:rounded-md fk:border fk:border-border fk:p-2 fk:corner-squircle",children:[jsx(t,{className:"fk:aspect-square fk:w-full fk:rounded-sm fk:corner-squircle"}),jsx(t,{className:"fk:mt-2 fk:h-3 fk:w-[75%]"}),jsx(t,{className:"fk:mt-1.5 fk:h-3 fk:w-[50%]"})]},`skeleton-${P}`))}):null,!i&&D.length===0?jsx("div",{className:"fk:flex fk:h-24 fk:items-center fk:justify-center fk:text-sm fk:text-muted-foreground",children:"No results."}):null,!i&&D.length>0?jsx("div",{className:"fk:grid fk:grid-cols-[repeat(auto-fill,minmax(10rem,1fr))] fk:pl-0.5 fk:gap-3",children:D.map(w=>jsx(To,{row:w},w.id))}):null]})]})]})}function To({row:e}){let n=e.original,t=E(n)||"Untitled",a=n.mimeType??"",i=Co(n.size),f=e.getIsSelected(),c=[a,i].filter(Boolean).join(" \xB7 ");return jsxs("div",{className:`fk:relative fk:rounded-md fk:border fk:p-2 fk:transition-colors ${f?"fk:border-primary fk:ring-1 fk:ring-primary/40 fk:bg-muted/40":"fk:border-border fk:bg-background fk:hover:border-muted-foreground/30"} fk:corner-squircle`,"data-state":f?"selected":void 0,children:[jsx("div",{className:"fk:absolute fk:left-3 fk:top-3 fk:z-10 fk:mix-blend-difference",children:jsx(o$2,{className:"fk:border-white!","aria-label":`Select ${t}`,checked:f,onCheckedChange:d=>{e.toggleSelected(!!d);},onClick:d=>d.stopPropagation()})}),jsx("div",{className:"fk:group fk:absolute fk:right-2 fk:top-2 fk:z-10 fk:mix-blend-difference",children:jsx(qe,{overlay:true,row:e})}),jsx(So,{asset:n,filename:t}),jsx("div",{className:"fk:mt-2 fk:truncate fk:text-xs fk:font-medium",title:t,children:t}),c?jsx("div",{className:"fk:mt-0.5 fk:truncate fk:text-[11px] fk:text-muted-foreground",title:c,children:c}):null]})}function So({asset:e,filename:n}){let[t,a]=useState(false),[i$1,f]=useState(false),c=e.url??"";if(!c&&!e.path)return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:corner-squircle",children:jsx("span",{className:"fk:text-xs fk:text-muted-foreground",children:"No preview"})});if(!G(e)||!c){let s=F(e),M=defaultStyles[s];return jsx("div",{className:"fk:flex fk:aspect-square fk:items-center fk:justify-center fk:rounded-sm fk:bg-muted fk:[&>svg]:h-12 fk:[&>svg]:w-auto fk:corner-squircle",children:jsx(bo,{extension:s,...M||{}})})}let b=H(c,{width:320,height:320}),v=c;function u(s){s.stopPropagation(),f(false),a(true);}function l$1(s){a(s),s||f(false);}return jsxs(Fragment,{children:[jsx("button",{className:`fk:aspect-square fk:w-full fk:cursor-zoom-in fk:overflow-hidden fk:rounded-sm fk:border-0 fk:p-0 ${wo} fk:corner-squircle`,onClick:u,type:"button",children:jsx("img",{alt:n,className:"fk:h-full fk:w-full fk:object-contain",src:b})}),jsx(c$2,{open:t,onOpenChange:l$1,children:jsxs(h$1,{className:"fk:sm:max-w-4xl fk:p-3",children:[jsxs(i,{children:[jsx(k,{className:"fk:sr-only",children:"Asset preview"}),jsx(l,{className:"fk:sr-only",children:"Enlarged asset preview"})]}),jsxs("div",{className:"fk:relative fk:flex fk:h-[min(85vh,56rem)] fk:w-full fk:items-center fk:justify-center fk:overflow-hidden fk:rounded-md fk:corner-squircle",children:[i$1?null:jsx(LoaderCircle,{"aria-label":"Loading image",className:"fk:absolute fk:h-8 fk:w-8 fk:animate-spin fk:text-muted-foreground"}),jsx("img",{alt:n,className:`fk:max-h-full fk:max-w-full fk:object-contain fk:transition-opacity ${i$1?"fk:opacity-100":"fk:opacity-0"}`,onError:()=>f(true),onLoad:()=>f(true),src:v})]})]})})]})}var Oo=[{value:"image/gif",label:"GIF",icon:ImagePlayIcon},{value:"image/jpeg",label:"JPEG",icon:ImageIcon},{value:"video/mp4",label:"MP4",icon:FilePlayIcon},{value:"image/png",label:"PNG",icon:LayersIcon},{value:"image/svg+xml",label:"SVG",icon:SplinePointerIcon},{value:"image/webp",label:"WebP",icon:ImageIcon}];function Ze({entityName:e,isUploading:n=false,table:t,viewMode:a,onUploadClick:i,onViewModeChange:f$1,onSearchLoadingChange:c$1,onSearchWhereChange:d}){let b=t.getState().columnFilters.length>0,{projectId:v}=useParams(),u$1=A(),{scope:l}=c(),[s,M]=useState(null),{currentProjectSchema:p}=f(),E=b$1(),[I,J]=useState(""),x=useRef({}),_=useRef({});function U(){return {searchRequests:{searches:[{collection:"_assets"},{collection:"_tags"}]},commonParams:{q:""}}}let F=useMemo(()=>U(),[]),[B$1,h]=useState(F),{results:D,isLoading:m}=a$1(v??"",B$1),C=useRef(""),S=I.trim(),z=B$1.commonParams.q??"",O=S.length>0&&(m||z!==S),w=useMemo(()=>Uo(g=>{h({...F,commonParams:{q:g}});},300),[F]);useEffect(()=>()=>{w.cancel();},[w]);let P=t.getSelectedRowModel().rows.map(g=>g.original._id),{data:r}=u({entityNamePlural:"_tags",schema:p,scope:l,variables:we,...Y}),V=useMemo(()=>(Array.isArray(r)?r:[]).map(N=>({_id:N._id,name:N.name})),[r]),X$1=useMemo(()=>V.map(g=>({value:g._id,label:g.name})),[V]),L=useCallback(()=>{if(!d)return;let g=[];Object.keys(x.current).length>0&&g.push(x.current),Object.keys(_.current).length>0&&g.push(_.current);let N=g.length===0?{}:g.length===1?g[0]:{AND:g},Z=JSON.stringify(N);C.current!==Z&&(C.current=Z,d(N));},[d]);function j(){w.cancel(),J(""),h({...F,commonParams:{q:""}}),x.current={},L();}async function K(){u$1({type:"AlertDialog",payload:{options:{dialogTitle:`Delete ${P.length} asset${P.length>1?"s":""}`,dialogMessage:P.length>1?"Are you sure you want to delete the selected assets? They will be deleted permanently.":"Are you sure you want to delete the selected asset? The item will be deleted permanently.",dialogCancelTitle:"Cancel",dialogActionLabel:"Delete",isDestructive:true,dialogActionCancel:()=>{},dialogActionSubmit:()=>{u$1({type:"DeleteEntity",_id:`delete-batch-${Date.now()}`,payload:{entityId:P,entityName:e,silent:true}}),t.resetRowSelection();}}}});}useEffect(()=>{c$1?.(O);},[O,c$1]),useEffect(()=>{if(!d)return;if(S.length===0){x.current={},L();return}if(O)return;let g=D??[],N={};if(g.length===0)N={_id:{in:[]}};else {let Z=g.filter(q=>q._entityNamePlural==="_assets").map(q=>q._id),xe=g.filter(q=>q._entityNamePlural==="_tags").map(q=>({tags:{some:{_id:{eq:q._id}}}})),Q=[];Z.length>0&&Q.push({_id:{in:Z}}),Q.push(...xe),Q.length===0?N={_id:{in:[]}}:Q.length===1?N=Q[0]:N={OR:Q};}x.current=N,L();},[L,O,d,D,S]);let y=JSON.stringify(t.getState().columnFilters);return useEffect(()=>{if(!d)return;let g=t.getState().columnFilters.find(q=>q.id==="mimeType"),N=Array.isArray(g?.value)?g?.value:[],Z=t.getState().columnFilters.find(q=>q.id==="tags"),xe=Array.isArray(Z?.value)?Z?.value:[],Q=[];if(N.length>0&&Q.push({mimeType:{in:N}}),xe.length>0){let q=xe.map(Ht=>({tags:{some:{_id:{eq:Ht}}}}));Q.push(q.length===1?q[0]:{OR:q});}Q.length===0?_.current={}:Q.length===1?_.current=Q[0]:_.current={AND:Q},L();},[y,L,d,t]),jsxs("div",{className:"fk:flex fk:items-center fk:justify-between fk:pr-3",children:[jsxs("div",{className:"fk:flex fk:flex-1 fk:items-center fk:space-x-2",children:[jsxs("div",{className:"fk:relative",children:[m?jsx(LoaderCircle,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50 fk:animate-spin"}):jsx(Search,{className:"fk:absolute fk:left-2 fk:top-2 fk:h-4 fk:w-4 fk:shrink-0 fk:opacity-50"}),jsx(s$1,{placeholder:"Search assets...",name:"search-assets",value:I,onChange:g=>{let{value:N}=g.target;if(J(N),N.trim().length===0){j();return}w(N.trim());},className:"fk:h-8 fk:w-37.5 fk:lg:w-70 fk:px-7"}),I?jsx(b$3,{"aria-label":"Clear search",className:"fk:absolute fk:right-1 fk:top-1 fk:h-6 fk:w-6 fk:text-muted-foreground fk:hover:text-foreground fk:hover:bg-foreground/10 fk:cursor-pointer fk:rounded-full fk:bg-transparent fk:corner-squircle",onClick:j,type:"button",children:jsx(X,{className:"fk:h-4 fk:w-4"})}):null]}),t.getColumn("mimeType")&&jsx(a$2,{column:t.getColumn("mimeType"),options:Oo,title:"File type"}),t.getColumn("tags")&&jsx(a$2,{column:t.getColumn("tags"),options:X$1,title:"Tags"}),b&&jsxs(b$3,{variant:"ghost",onClick:()=>{t.resetColumnFilters(),_.current={},L();},className:"fk:h-8 fk:px-2 fk:lg:px-3",children:["Reset",jsx(X,{className:"fk:ml-2 fk:h-4 fk:w-4"})]}),jsx(B,{table:t})]}),P.length>0?jsx("div",{className:"fk:flex fk:items-center fk:gap-2",children:jsxs(e$2,{children:[jsx(ma,{disabled:!E,children:jsx(g$1,{asChild:true,children:jsxs(b$3,{className:"fk:h-8 fk:mr-2 fk:lg:flex",disabled:!E,size:"sm",variant:"secondary",children:["Actions ",jsx(ListChecks,{className:"fk:ml-2 fk:h-4 fk:w-4"})]})})}),jsxs(h$2,{align:"end",className:"fk:w-[240px]",children:[jsxs(j$2,{onClick:()=>M("add"),children:[jsx(TagIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Add tag"]}),jsxs(j$2,{onClick:()=>M("remove"),children:[jsx(MinusIcon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Remove tag"]}),jsx(o,{}),jsxs(j$2,{onClick:K,className:"fk:text-destructive",children:[jsx(Trash2Icon,{className:"fk:mr-2 fk:h-4 fk:w-4"})," Delete asset",P.length>1?"s":""," (",P.length,")"]})]})]})}):null,jsxs("div",{className:"fk:ml-auto fk:flex fk:items-center fk:gap-2",children:[jsxs(c$4,{size:"sm",type:"single",value:a,onValueChange:g=>{(g==="list"||g==="grid")&&f$1(g);},children:[jsx(d$1,{"aria-label":"Grid view",value:"grid",children:jsx(LayoutGrid,{className:"fk:h-4 fk:w-4"})}),jsx(d$1,{"aria-label":"List view",value:"list",children:jsx(List,{className:"fk:h-4 fk:w-4"})})]}),jsx(ma,{disabled:!E,children:jsxs(b$3,{"aria-busy":n,className:"fk:h-8 fk:lg:flex",disabled:!E||n,onClick:i,size:"sm",variant:"default",children:[n?jsx(LoaderCircle,{className:"fk:mr-2 fk:h-4 fk:w-4 fk:animate-spin"}):null,"Upload assets"]})})]}),s!==null?jsx(Ve,{assetIds:P,mode:s,onCompleted:()=>t.resetRowSelection(),onModeChange:M}):null]})}function Uo(e,n=300){let t,a=function(...i){t!==void 0&&clearTimeout(t),t=setTimeout(()=>{t=void 0,e.apply(this,i);},n);};return a.cancel=()=>{t!==void 0&&(clearTimeout(t),t=void 0);},a}var Qo=4*1024*1024;function Gt(){let{projectId:e}=useParams(),n=c$3(),t=b$1(),[a,i]=useState(false);async function f(c){if(!(!t||a)&&!(c&&c.length===0))try{await n({files:c,maxBytes:Qo,multiple:!0,onUploadStart:()=>{i(!0);},projectId:e});}finally{i(false);}}return {canMutate:t,isUploading:a,uploadFiles:c=>f(c),uploadFromDialog:()=>f()}}var Wt="flexkit-asset-manager:viewMode";function $t(){if(typeof localStorage>"u")return "grid";try{let e=localStorage.getItem(Wt);if(e==="list"||e==="grid")return e}catch{}return "grid"}function Jt(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(Wt,e);}catch{}}var Me=36,Jo=[{_updatedAt:"DESC"},{_id:"DESC"}];function Xt(){let e="_assets",{search:n}=useLocation(),a=new URLSearchParams(n).get("id"),{scope:i}=c(),{schemaErrorMessage:f$1}=s(),{currentProject:c$1}=f(),d=c$1?.schema??[],[b$1,v$1]=useState([]),[u$1,l]=useState(()=>$t()),s$1=J({attributesSchema:b.attributes,actionsComponent:y=>jsx(qe,{row:y}),checkboxSelect:"multiple",enableColumnSorting:true}),[M,p]=useState({}),[E,I]=useState(false),{canMutate:J$1,isUploading:x,uploadFiles:_,uploadFromDialog:U}=Gt(),F=useMemo(()=>{let y=a?{_id:{eq:a}}:{NOT:{path:{eq:null}}};return !M||Object.keys(M).length===0||a?y:{AND:[y,M]}},[a,M]),B=useMemo(()=>{if(b$1.length===0)return Jo;let y=b$1.map(({id:N,desc:Z})=>({[N]:Z?"DESC":"ASC"}));return y.some(N=>"_id"in N)?y:[...y,{_id:"DESC"}]},[b$1]),h=useMemo(()=>({where:F,offset:0,limit:Me,sort:B}),[F,B]);function D(y){v$1(y);}function m(y){l(y),Jt(y);}let{isLoading:C,isLoadingMore:S,fetchMore:z,count:O,data:w$1,isProjectDisabled:P}=u({entityNamePlural:e,schema:d,scope:i,variables:h,selection:"list"}),r=E||C&&(w$1==null||w$1.length===0),V=w$1?.length??0,X=!E&&O>0&&V>0&&V<O,L=useCallback(()=>{z({variables:{offset:0,limit:Me}});},[z]),j=useMemo(()=>Array.from({length:Me},(y,g)=>({_id:`loading-${g}`})),[]),K=useMemo(()=>Xo(s$1),[s$1]);return P?jsx("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:jsx(v,{})}):jsxs("div",{className:"fk:flex fk:flex-col fk:h-full fk:pl-3",children:[jsx(w,{}),jsxs("div",{className:"fk:mb-4 fk:flex fk:items-center fk:gap-2 fk:pr-3",children:[jsx("h2",{className:"fk:text-lg fk:font-semibold fk:leading-none fk:tracking-tight",children:"Asset Manager"}),r?null:jsxs("span",{className:"fk:ml-auto fk:text-sm fk:font-normal fk:text-muted-foreground",children:[O.toLocaleString()," ",O===1?"record":"records"]})]}),f$1?null:jsx(_t,{disabled:!J$1||x,onDropFiles:_,children:u$1==="list"?jsx(x$1,{classNames:{row:"fk:h-20"},columns:r?K:s$1,data:r?j:w$1??[],entityName:b.name,hasMore:X,isLoadingMore:S,pageSize:Me,sorting:b$1,onLoadMore:L,onSortingChange:D,toolbarComponent:y=>jsx(Ze,{entityName:b.name,isUploading:x,table:y,viewMode:u$1,onSearchLoadingChange:I,onSearchWhereChange:p,onUploadClick:U,onViewModeChange:m})}):jsx(Ot,{columns:s$1,data:r?[]:w$1??[],entityName:b.name,hasMore:X,isLoading:r,isLoadingMore:S,pageSize:Me,sorting:b$1,onLoadMore:L,onSortingChange:D,toolbarComponent:y=>jsx(Ze,{entityName:b.name,isUploading:x,table:y,viewMode:u$1,onSearchLoadingChange:I,onSearchWhereChange:p,onUploadClick:U,onViewModeChange:m})})}),jsx(Outlet,{})]})}function Xo(e){return e.map(n=>({...n,cell:()=>jsx(t,{className:"fk:h-4 fk:w-full",style:{marginTop:"7px",marginBottom:"6px"}})}))}function On(){return jsxs(x,{orientation:"horizontal",className:"fk:h-full",children:[jsx(y,{className:"fk:p-3",defaultSize:"82%",children:jsx("div",{className:"fk:flex fk:flex-col fk:h-full",children:jsx(Xt,{})})}),jsx(z,{className:"fk:hover:bg-blue-500 fk:transition-colors",withHandle:true}),jsx(y,{defaultSize:"18%",minSize:"10%",children:jsx("div",{className:"fk:sm:hidden fk:md:block",children:jsx(Et,{})})})]})}export{On as Root};//# sourceMappingURL=root-A4VHAEK5.js.map
23
- //# sourceMappingURL=root-A4VHAEK5.js.map