@pickaxeproject/react 6.1.0 → 6.1.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/index3.js +1 -0
- package/dist/cjs/_virtual/index4.js +1 -0
- package/dist/cjs/_virtual/react-is.development.js +1 -0
- package/dist/cjs/_virtual/react-is.production.min.js +1 -0
- package/dist/cjs/common/utils.js +1 -1
- package/dist/cjs/components/Icons/pencil.svg.js +1 -0
- package/dist/cjs/components/Pickaxe/Addons/Auth/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Navbar/NavPill.js +1 -0
- package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeAvatar.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeCommon.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeCurrency.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/hooks/studio/useStudio.js +1 -0
- package/dist/cjs/node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js +1 -0
- package/dist/cjs/node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js +1 -0
- package/dist/cjs/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +7 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +1 -0
- package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +9 -0
- package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +9 -0
- package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +1 -0
- package/dist/cjs/src/common/utils.d.ts +2 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Auth/Provider.d.ts +4 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Auth/hooks/useAuthContext.d.ts +4 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Navbar/NavPill.d.ts +15 -0
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +21 -4
- package/dist/cjs/src/components/Pickaxe/ResponseProvider.d.ts +7 -3
- package/dist/cjs/src/components/Pickaxe/common/AccessGroupCardPreview.d.ts +9 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeAvatar.d.ts +16 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeCommon.d.ts +2 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeCurrency.d.ts +7 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeUpgradeCard.d.ts +1 -1
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +10 -1
- package/dist/cjs/src/hooks/studio/useStudio.d.ts +5 -0
- package/dist/cjs/src/types/response.d.ts +8 -0
- package/dist/esm/_virtual/index3.js +1 -0
- package/dist/esm/_virtual/index4.js +1 -0
- package/dist/esm/_virtual/react-is.development.js +1 -0
- package/dist/esm/_virtual/react-is.production.min.js +1 -0
- package/dist/esm/common/utils.js +1 -1
- package/dist/esm/components/Icons/pencil.svg.js +1 -0
- package/dist/esm/components/Pickaxe/Addons/Auth/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Navbar/NavPill.js +1 -0
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
- package/dist/esm/components/Pickaxe/Form/index.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeAvatar.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeCommon.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeCurrency.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/hooks/studio/useStudio.js +1 -0
- package/dist/esm/node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js +1 -0
- package/dist/esm/node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js +1 -0
- package/dist/esm/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +6 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +1 -0
- package/dist/esm/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +9 -0
- package/dist/esm/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +9 -0
- package/dist/esm/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +1 -0
- package/dist/esm/src/common/utils.d.ts +2 -0
- package/dist/esm/src/components/Pickaxe/Addons/Auth/Provider.d.ts +4 -0
- package/dist/esm/src/components/Pickaxe/Addons/Auth/hooks/useAuthContext.d.ts +4 -0
- package/dist/esm/src/components/Pickaxe/Addons/Navbar/NavPill.d.ts +15 -0
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +21 -4
- package/dist/esm/src/components/Pickaxe/ResponseProvider.d.ts +7 -3
- package/dist/esm/src/components/Pickaxe/common/AccessGroupCardPreview.d.ts +9 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeAvatar.d.ts +16 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeCommon.d.ts +2 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeCurrency.d.ts +7 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeUpgradeCard.d.ts +1 -1
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +10 -1
- package/dist/esm/src/hooks/studio/useStudio.d.ts +5 -0
- package/dist/esm/src/types/response.d.ts +8 -0
- package/package.json +209 -203
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,r;Object.defineProperty(exports,"__esModule",{value:!0}),exports.__require=function(){return r?e:(r=1,e=Function.call.bind(Object.prototype.hasOwnProperty))};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../../../../../_virtual/react-is.development.js");
|
|
2
|
+
/** @license React v16.13.1
|
|
3
|
+
* react-is.development.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/exports.__require=function(){return e||(e=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,o=e?Symbol.for("react.portal"):60106,n=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,c=e?Symbol.for("react.profiler"):60114,a=e?Symbol.for("react.provider"):60109,f=e?Symbol.for("react.context"):60110,_=e?Symbol.for("react.async_mode"):60111,p=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,i=e?Symbol.for("react.suspense"):60113,l=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,x=e?Symbol.for("react.block"):60121,d=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,S=e?Symbol.for("react.scope"):60119;function $(e){if("object"==typeof e&&null!==e){var r=e.$$typeof;switch(r){case t:var l=e.type;switch(l){case _:case p:case n:case c:case s:case i:return l;default:var x=l&&l.$$typeof;switch(x){case f:case u:case m:case y:case a:return x;default:return r}}case o:return r}}}var v=_,M=p,C=f,w=a,P=t,h=u,j=n,E=m,R=y,g=o,A=c,F=s,I=i,z=!1;function O(e){return $(e)===p}r.__exports.AsyncMode=v,r.__exports.ConcurrentMode=M,r.__exports.ContextConsumer=C,r.__exports.ContextProvider=w,r.__exports.Element=P,r.__exports.ForwardRef=h,r.__exports.Fragment=j,r.__exports.Lazy=E,r.__exports.Memo=R,r.__exports.Portal=g,r.__exports.Profiler=A,r.__exports.StrictMode=F,r.__exports.Suspense=I,r.__exports.isAsyncMode=function(e){return z||(z=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),O(e)||$(e)===_},r.__exports.isConcurrentMode=O,r.__exports.isContextConsumer=function(e){return $(e)===f},r.__exports.isContextProvider=function(e){return $(e)===a},r.__exports.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},r.__exports.isForwardRef=function(e){return $(e)===u},r.__exports.isFragment=function(e){return $(e)===n},r.__exports.isLazy=function(e){return $(e)===m},r.__exports.isMemo=function(e){return $(e)===y},r.__exports.isPortal=function(e){return $(e)===o},r.__exports.isProfiler=function(e){return $(e)===c},r.__exports.isStrictMode=function(e){return $(e)===s},r.__exports.isSuspense=function(e){return $(e)===i},r.__exports.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===n||e===p||e===c||e===s||e===i||e===l||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===y||e.$$typeof===a||e.$$typeof===f||e.$$typeof===u||e.$$typeof===d||e.$$typeof===b||e.$$typeof===S||e.$$typeof===x)},r.__exports.typeOf=$}()),r.__exports};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../../../../../_virtual/react-is.production.min.js");
|
|
2
|
+
/** @license React v16.13.1
|
|
3
|
+
* react-is.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/exports.__require=function(){if(e)return r.__exports;e=1;var t="function"==typeof Symbol&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,s=t?Symbol.for("react.fragment"):60107,c=t?Symbol.for("react.strict_mode"):60108,f=t?Symbol.for("react.profiler"):60114,_=t?Symbol.for("react.provider"):60109,p=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,i=t?Symbol.for("react.concurrent_mode"):60111,a=t?Symbol.for("react.forward_ref"):60112,y=t?Symbol.for("react.suspense"):60113,l=t?Symbol.for("react.suspense_list"):60120,m=t?Symbol.for("react.memo"):60115,x=t?Symbol.for("react.lazy"):60116,b=t?Symbol.for("react.block"):60121,S=t?Symbol.for("react.fundamental"):60117,$=t?Symbol.for("react.responder"):60118,d=t?Symbol.for("react.scope"):60119;function M(e){if("object"==typeof e&&null!==e){var r=e.$$typeof;switch(r){case o:switch(e=e.type){case u:case i:case s:case f:case c:case y:return e;default:switch(e=e&&e.$$typeof){case p:case a:case x:case m:case _:return e;default:return r}}case n:return r}}}function v(e){return M(e)===i}return r.__exports.AsyncMode=u,r.__exports.ConcurrentMode=i,r.__exports.ContextConsumer=p,r.__exports.ContextProvider=_,r.__exports.Element=o,r.__exports.ForwardRef=a,r.__exports.Fragment=s,r.__exports.Lazy=x,r.__exports.Memo=m,r.__exports.Portal=n,r.__exports.Profiler=f,r.__exports.StrictMode=c,r.__exports.Suspense=y,r.__exports.isAsyncMode=function(e){return v(e)||M(e)===u},r.__exports.isConcurrentMode=v,r.__exports.isContextConsumer=function(e){return M(e)===p},r.__exports.isContextProvider=function(e){return M(e)===_},r.__exports.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},r.__exports.isForwardRef=function(e){return M(e)===a},r.__exports.isFragment=function(e){return M(e)===s},r.__exports.isLazy=function(e){return M(e)===x},r.__exports.isMemo=function(e){return M(e)===m},r.__exports.isPortal=function(e){return M(e)===n},r.__exports.isProfiler=function(e){return M(e)===f},r.__exports.isStrictMode=function(e){return M(e)===c},r.__exports.isSuspense=function(e){return M(e)===y},r.__exports.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===s||e===i||e===f||e===c||e===y||e===l||"object"==typeof e&&null!==e&&(e.$$typeof===x||e.$$typeof===m||e.$$typeof===_||e.$$typeof===p||e.$$typeof===a||e.$$typeof===S||e.$$typeof===$||e.$$typeof===d||e.$$typeof===b)},r.__exports.typeOf=M,r.__exports};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../../../../_virtual/index4.js"),o=require("./cjs/react-is.production.min.js"),s=require("./cjs/react-is.development.js");exports.__require=function(){return e||(e=1,"production"===process.env.NODE_ENV?r.__module.exports=o.__require():r.__module.exports=s.__require()),r.__module.exports};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Ref } from "react";
|
|
2
|
+
export declare const COOKIE_USER_ID = "PXE-uid";
|
|
2
3
|
export declare const generateId: (length: number, prefix?: string, suffix?: string) => string;
|
|
3
4
|
export declare const randomStr: (len: number, charOnly?: boolean) => string;
|
|
4
5
|
export declare const extractUrlsFromText: (text: string) => string[];
|
|
5
6
|
export declare const formatBytes: (bytes: number, decimals?: number) => string;
|
|
6
7
|
export declare const getCookie: (name: string) => string | null;
|
|
7
8
|
export declare const deleteCookie: (name: string) => void;
|
|
9
|
+
export declare const initializeEmbedUserId: () => string;
|
|
8
10
|
export declare const getAuthToken: (studioId: string) => string | null;
|
|
9
11
|
export declare const setAuthToken: (name: string, token: string) => void;
|
|
10
12
|
export declare const deleteAuthToken: (name: string) => void;
|
|
@@ -2,6 +2,7 @@ import type { SetState } from "../../../../types/common";
|
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
type AuthContextType = {
|
|
4
4
|
emailInput: string;
|
|
5
|
+
redirectUrl: string | null;
|
|
5
6
|
token: string | null;
|
|
6
7
|
isLoggedIn: boolean;
|
|
7
8
|
isLoggedOut: boolean;
|
|
@@ -9,12 +10,15 @@ type AuthContextType = {
|
|
|
9
10
|
isSending: boolean;
|
|
10
11
|
isResendDisabled: boolean;
|
|
11
12
|
isSent: boolean;
|
|
13
|
+
isPricingAuth: boolean;
|
|
12
14
|
setEmailInput: SetState<string>;
|
|
13
15
|
setToken: SetState<string | null>;
|
|
14
16
|
setIsLoggingIn: SetState<boolean>;
|
|
15
17
|
setIsSending: SetState<boolean>;
|
|
16
18
|
setIsResendDisabled: SetState<boolean>;
|
|
17
19
|
setIsSent: SetState<boolean>;
|
|
20
|
+
setIsPricingAuth: SetState<boolean>;
|
|
21
|
+
setRedirectUrl: SetState<string | null>;
|
|
18
22
|
};
|
|
19
23
|
export interface IAuthProviderProps {
|
|
20
24
|
children: ReactNode;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const useAuthContext: () => {
|
|
2
2
|
emailInput: string;
|
|
3
|
+
redirectUrl: string | null;
|
|
3
4
|
token: string | null;
|
|
4
5
|
isLoggedIn: boolean;
|
|
5
6
|
isLoggedOut: boolean;
|
|
@@ -7,10 +8,13 @@ export declare const useAuthContext: () => {
|
|
|
7
8
|
isSending: boolean;
|
|
8
9
|
isResendDisabled: boolean;
|
|
9
10
|
isSent: boolean;
|
|
11
|
+
isPricingAuth: boolean;
|
|
10
12
|
setEmailInput: import("../../../../../types/common").SetState<string>;
|
|
11
13
|
setToken: import("../../../../../types/common").SetState<string | null>;
|
|
12
14
|
setIsLoggingIn: import("../../../../../types/common").SetState<boolean>;
|
|
13
15
|
setIsSending: import("../../../../../types/common").SetState<boolean>;
|
|
14
16
|
setIsResendDisabled: import("../../../../../types/common").SetState<boolean>;
|
|
15
17
|
setIsSent: import("../../../../../types/common").SetState<boolean>;
|
|
18
|
+
setIsPricingAuth: import("../../../../../types/common").SetState<boolean>;
|
|
19
|
+
setRedirectUrl: import("../../../../../types/common").SetState<string | null>;
|
|
16
20
|
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface NavPillProps {
|
|
2
|
+
text: string;
|
|
3
|
+
icon?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const NavPill: ({ text, icon, className, onClick }: NavPillProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
interface EditableNavPillProps extends NavPillProps {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
onRename: (newName: string) => Promise<void>;
|
|
11
|
+
onDelete: () => Promise<void>;
|
|
12
|
+
isDarkGlass?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const EditableNavPill: ({ text, className, onRename, onDelete, isDarkGlass, }: EditableNavPillProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -10,6 +10,7 @@ export type PickaxeTranslations = {
|
|
|
10
10
|
};
|
|
11
11
|
export type PickaxeProviderStyles = {
|
|
12
12
|
theme: "light" | "dark";
|
|
13
|
+
portalTheme?: "light" | "dark";
|
|
13
14
|
font: string;
|
|
14
15
|
fontSize: StudioFontSize;
|
|
15
16
|
formFieldStyle: StudioFormFieldStyle;
|
|
@@ -35,7 +36,8 @@ export type PickaxeMisc = {
|
|
|
35
36
|
isDescription: boolean;
|
|
36
37
|
isHistory?: boolean;
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
+
type ValidationStatus = "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
40
|
+
export type PickaxeDeploymentEmbedType = "inline" | "fab" | "popup" | "chat-input" | "direct-link";
|
|
39
41
|
export type PickaxeDeploymentDimensions = {
|
|
40
42
|
width: {
|
|
41
43
|
value: number;
|
|
@@ -53,6 +55,10 @@ export type PickaxeDeploymentMisc = {
|
|
|
53
55
|
popupText?: string;
|
|
54
56
|
fabImage?: string;
|
|
55
57
|
};
|
|
58
|
+
export type AccessGroup = {
|
|
59
|
+
limit: number;
|
|
60
|
+
accessGroupId: string;
|
|
61
|
+
};
|
|
56
62
|
type PickaxeContextType = {
|
|
57
63
|
origin: PickaxeHistoryOriginType;
|
|
58
64
|
contextId: string;
|
|
@@ -63,8 +69,11 @@ type PickaxeContextType = {
|
|
|
63
69
|
senderType: PickaxeHistorySenderType;
|
|
64
70
|
deploymentId?: string;
|
|
65
71
|
deploymentType?: PickaxeDeploymentEmbedType;
|
|
72
|
+
validationStatus: ValidationStatus;
|
|
66
73
|
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
67
74
|
deploymentMisc?: PickaxeDeploymentMisc;
|
|
75
|
+
portalId?: string;
|
|
76
|
+
accessGroup?: AccessGroup | null;
|
|
68
77
|
pickaxe: LimitedPickaxe | null;
|
|
69
78
|
styles: PickaxeProviderStyles;
|
|
70
79
|
colors: PickaxeProviderColors;
|
|
@@ -86,12 +95,16 @@ type PickaxeContextType = {
|
|
|
86
95
|
isRtl: boolean;
|
|
87
96
|
isEmbed: boolean;
|
|
88
97
|
isDropShadow: boolean;
|
|
89
|
-
isEmailLogin: boolean;
|
|
90
98
|
allowGuestUsage: boolean;
|
|
99
|
+
stripeAccountId: string | null;
|
|
100
|
+
clientSecret: string | null;
|
|
101
|
+
preventInitialSessionId: boolean;
|
|
91
102
|
setContextId: SetState<string>;
|
|
92
103
|
setPickaxeId: SetState<string>;
|
|
93
104
|
setSessionId: SetState<string>;
|
|
105
|
+
setAccessGroup: SetState<AccessGroup | null>;
|
|
94
106
|
setLastSessionId: SetState<string>;
|
|
107
|
+
setValidationStatus: SetState<ValidationStatus>;
|
|
95
108
|
setSender: SetState<string | undefined>;
|
|
96
109
|
setSenderType: SetState<PickaxeHistorySenderType>;
|
|
97
110
|
setPickaxe: SetState<LimitedPickaxe | null>;
|
|
@@ -99,6 +112,8 @@ type PickaxeContextType = {
|
|
|
99
112
|
setIsNewChat: SetState<boolean>;
|
|
100
113
|
setIsShowIceBreaker: SetState<boolean>;
|
|
101
114
|
setIsShowFeedbackMessage: SetState<boolean>;
|
|
115
|
+
setStripeAccountId: SetState<string | null>;
|
|
116
|
+
setClientSecret: SetState<string | null>;
|
|
102
117
|
onGenerateComplete?: (responseId: string) => void;
|
|
103
118
|
};
|
|
104
119
|
export interface IPickaxeProviderProps {
|
|
@@ -107,6 +122,7 @@ export interface IPickaxeProviderProps {
|
|
|
107
122
|
sender?: string;
|
|
108
123
|
senderType: PickaxeHistorySenderType;
|
|
109
124
|
deploymentId?: string;
|
|
125
|
+
portalId?: string;
|
|
110
126
|
deploymentType?: PickaxeDeploymentEmbedType;
|
|
111
127
|
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
112
128
|
deploymentMisc?: PickaxeDeploymentMisc;
|
|
@@ -127,10 +143,11 @@ export interface IPickaxeProviderProps {
|
|
|
127
143
|
isRtl?: boolean;
|
|
128
144
|
isEmbed?: boolean;
|
|
129
145
|
isDropShadow?: boolean;
|
|
130
|
-
isEmailLogin?: boolean;
|
|
131
146
|
allowGuestUsage?: boolean;
|
|
147
|
+
preventInitialSessionId?: boolean;
|
|
132
148
|
onGenerateComplete?: (responseId: string) => void;
|
|
149
|
+
onSessionIdChange?: (sessionId: string) => void;
|
|
133
150
|
}
|
|
134
151
|
export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
|
|
135
|
-
export declare const PickaxeProvider: ({ children, origin, sender: _sender, senderType: _senderType, deploymentId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow,
|
|
152
|
+
export declare const PickaxeProvider: ({ children, origin, sender: _sender, senderType: _senderType, deploymentId, portalId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow, allowGuestUsage, preventInitialSessionId, onGenerateComplete, onSessionIdChange, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
136
153
|
export {};
|
|
@@ -3,9 +3,13 @@ import type { MemoryStoredChatMessage, MemoryStoredFormResponse } from "../../ty
|
|
|
3
3
|
import { type ReactNode } from "react";
|
|
4
4
|
export type ResponseStatus = "fetching" | "streaming" | "idle";
|
|
5
5
|
export type PickaxeLimitData = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
limitMessage: string;
|
|
7
|
+
buyUses?: any[];
|
|
8
|
+
upgradeGroups?: any[];
|
|
9
|
+
limitLink?: string;
|
|
10
|
+
customLink?: string;
|
|
11
|
+
limitCTA: string;
|
|
12
|
+
accessGroupId: string;
|
|
9
13
|
};
|
|
10
14
|
type ResponseContextType = {
|
|
11
15
|
messages: MemoryStoredChatMessage[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
interface AccessGroupCardPreviewProps {
|
|
3
|
+
data: any;
|
|
4
|
+
accessGroupId?: string;
|
|
5
|
+
upgradeUrl?: string | null;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
declare const AccessGroupCardPreview: ({ data, children, upgradeUrl, }: AccessGroupCardPreviewProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default AccessGroupCardPreview;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
|
3
|
+
declare const Avatar: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
4
|
+
declare const AvatarImage: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarImageProps & React.RefAttributes<HTMLImageElement>, "ref"> & React.RefAttributes<HTMLImageElement>>;
|
|
5
|
+
declare const AvatarFallback: React.ForwardRefExoticComponent<Omit<AvatarPrimitive.AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
6
|
+
export type AvatarGroupItem = {
|
|
7
|
+
src?: string;
|
|
8
|
+
initials: string;
|
|
9
|
+
};
|
|
10
|
+
export interface AvatarGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
data: AvatarGroupItem[];
|
|
12
|
+
max?: number;
|
|
13
|
+
avatarClassName?: string;
|
|
14
|
+
}
|
|
15
|
+
declare const AvatarGroup: React.ForwardRefExoticComponent<AvatarGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
export { Avatar, AvatarImage, AvatarFallback, AvatarGroup };
|
|
@@ -3,5 +3,5 @@ interface PickaxeUpgradeCardProps {
|
|
|
3
3
|
iconClassName?: string;
|
|
4
4
|
htmlClassName?: string;
|
|
5
5
|
}
|
|
6
|
-
declare const PickaxeUpgradeCard: ({ className, iconClassName, htmlClassName, }: PickaxeUpgradeCardProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const PickaxeUpgradeCard: ({ className, iconClassName, htmlClassName, }: PickaxeUpgradeCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
7
|
export default PickaxeUpgradeCard;
|
|
@@ -8,8 +8,11 @@ export declare const usePickaxeContext: () => {
|
|
|
8
8
|
senderType: import("../../types/history").PickaxeHistorySenderType;
|
|
9
9
|
deploymentId?: string | undefined;
|
|
10
10
|
deploymentType?: import("../../components/Pickaxe/Provider").PickaxeDeploymentEmbedType | undefined;
|
|
11
|
+
validationStatus: "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
11
12
|
deploymentDimensions?: import("../../components/Pickaxe/Provider").PickaxeDeploymentDimensions | undefined;
|
|
12
13
|
deploymentMisc?: import("../../components/Pickaxe/Provider").PickaxeDeploymentMisc | undefined;
|
|
14
|
+
portalId?: string | undefined;
|
|
15
|
+
accessGroup?: import("../../components/Pickaxe/Provider").AccessGroup | null | undefined;
|
|
13
16
|
pickaxe: import("../../types/pickaxe").LimitedPickaxe | null;
|
|
14
17
|
styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
|
|
15
18
|
colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
|
|
@@ -31,12 +34,16 @@ export declare const usePickaxeContext: () => {
|
|
|
31
34
|
isRtl: boolean;
|
|
32
35
|
isEmbed: boolean;
|
|
33
36
|
isDropShadow: boolean;
|
|
34
|
-
isEmailLogin: boolean;
|
|
35
37
|
allowGuestUsage: boolean;
|
|
38
|
+
stripeAccountId: string | null;
|
|
39
|
+
clientSecret: string | null;
|
|
40
|
+
preventInitialSessionId: boolean;
|
|
36
41
|
setContextId: import("../../types/common").SetState<string>;
|
|
37
42
|
setPickaxeId: import("../../types/common").SetState<string>;
|
|
38
43
|
setSessionId: import("../../types/common").SetState<string>;
|
|
44
|
+
setAccessGroup: import("../../types/common").SetState<import("../../components/Pickaxe/Provider").AccessGroup | null>;
|
|
39
45
|
setLastSessionId: import("../../types/common").SetState<string>;
|
|
46
|
+
setValidationStatus: import("../../types/common").SetState<"loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout">;
|
|
40
47
|
setSender: import("../../types/common").SetState<string | undefined>;
|
|
41
48
|
setSenderType: import("../../types/common").SetState<import("../../types/history").PickaxeHistorySenderType>;
|
|
42
49
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
|
|
@@ -44,5 +51,7 @@ export declare const usePickaxeContext: () => {
|
|
|
44
51
|
setIsNewChat: import("../../types/common").SetState<boolean>;
|
|
45
52
|
setIsShowIceBreaker: import("../../types/common").SetState<boolean>;
|
|
46
53
|
setIsShowFeedbackMessage: import("../../types/common").SetState<boolean>;
|
|
54
|
+
setStripeAccountId: import("../../types/common").SetState<string | null>;
|
|
55
|
+
setClientSecret: import("../../types/common").SetState<string | null>;
|
|
47
56
|
onGenerateComplete?: ((responseId: string) => void) | undefined;
|
|
48
57
|
};
|
|
@@ -9,3 +9,11 @@ export type MemoryStoredFormResponse = {
|
|
|
9
9
|
messageCount: number;
|
|
10
10
|
sentAt: Date;
|
|
11
11
|
};
|
|
12
|
+
export interface LimitData {
|
|
13
|
+
limitMessage: string;
|
|
14
|
+
buyUses?: any[];
|
|
15
|
+
upgradeGroups?: any[];
|
|
16
|
+
limitLink?: string;
|
|
17
|
+
accessGroupId?: string;
|
|
18
|
+
limitCTA?: string;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={exports:{}};export{e as __module};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={exports:{}};export{e as __module};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r={};export{r as __exports};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r={};export{r as __exports};
|
package/dist/esm/common/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{parse as t}from"tldts";const e="PXE-uid",o=(t,e="",o="")=>{let r="";for(let e=0;e<t;e++){r+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return e+r+o},r=(t,e=!1)=>{let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";e&&(o=o.replace(/[0-9]/g,""));let r="";for(let e=0;e<t;e++)r+=o.charAt(Math.floor(Math.random()*o.length));return r},n=t=>{const e=t.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(e))},l=(t,e=2)=>{if(!+t)return"0 Bytes";const o=e<0?0:e,r=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,r)).toFixed(o))} ${["Bytes","KB","MB","PB","EB"][r]}`},c=t=>{try{const e=document.cookie.split("; ");for(const o of e){const[e,r]=o.split("=");if(e===t)return r}return null}catch(t){return console.error("[pxe] failed to get cookie",t),null}},a=t=>{document.cookie=t+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},i=()=>{try{const o=c(e);if(!o){const o=r(28),n=new Date;n.setFullYear(n.getFullYear()+1);let l=window.location.hostname;const c=t(l).domain;if(c)l=`.${c}`;else{const t=l.split(":")[0],e=t.split(".");l=t,e.length>=2&&(l=`.${e.slice(-2).join(".")}`)}return document.cookie=`${e}=${o};Path=/; Domain=${l}; Expires=${n.toUTCString()}`,o}return o}catch(t){return console.error("[pxe-embed] failed to initialized embed user id",t),r(28)}},u=t=>{try{if("undefined"==typeof window)return null;let e=null;return e=new URLSearchParams(window.location.search).get("pxtoken"),e||(e=localStorage.getItem(`PXE-token-${t}`)),e||(e=c(`PXE-token-${t}`)),e||(e=c(`__Secure-PS-${t}.session-token`)),e?decodeURIComponent(e):null}catch(t){return null}},s=(t,e)=>{try{if("undefined"==typeof window)return;localStorage.setItem(t,e)}catch(t){console.error("[pxe] failed to set auth token",t)}},d=t=>{try{if("undefined"==typeof window)return;localStorage.removeItem(t)}catch(t){console.error("[pxe] failed to delete auth token",t)}};function f(...t){return e=>{for(const o of t)o&&("function"==typeof o?o(e):o.current=e)}}const h=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(t){return!0}},p=t=>{try{return JSON.parse(t)}catch(t){return null}};export{e as COOKIE_USER_ID,d as deleteAuthToken,a as deleteCookie,n as extractUrlsFromText,l as formatBytes,o as generateId,u as getAuthToken,c as getCookie,i as initializeEmbedUserId,h as isInIframe,f as mergeRefs,r as randomStr,p as safeJSONParse,s as setAuthToken};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as r from"react";var e;function t(){return t=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},t.apply(null,arguments)}var n=n=>r.createElement("svg",t({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 18 18"},n),e||(e=r.createElement("path",{fill:"currentColor",d:"m11.06 6.02.92.92L2.92 16H2v-.92zM14.66 0c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83a.996.996 0 0 0 0-1.41L15.37.29c-.2-.2-.45-.29-.71-.29m-3.6 3.19L0 14.25V18h3.75L14.81 6.94z"})));export{n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useState as s,createContext as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useState as s,createContext as t}from"react";const i=t({}),n=({children:t})=>{const[n,r]=s(""),[g,d]=s(null),[l,o]=s(null),[c,u]=s(!1),[a,I]=s(!1),[m,p]=s(!1),[h,L]=s(!1),[S,b]=s(!1);return e(i.Provider,Object.assign({value:{emailInput:n,redirectUrl:l,token:g,isLoggedIn:!!g,isLoggedOut:!g,isLoggingIn:c,isSending:m,isResendDisabled:h,isSent:S,isPricingAuth:a,setIsPricingAuth:I,setRedirectUrl:o,setEmailInput:r,setToken:d,setIsLoggingIn:u,setIsSending:p,setIsResendDisabled:L,setIsSent:b}},{children:t}))};export{i as AuthContext,n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useEffect as
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useEffect as t}from"react";import{usePickaxeContext as i}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as o}from"./useAuthContext.js";import{useAuthVerify as r}from"./useAuthVerify.js";import{getAuthToken as s,deleteAuthToken as n,setAuthToken as d}from"../../../../../common/utils.js";import a from"../../../../../common/api/pickaxe.js";import m from"../../../../../common/error.js";import{useResponseContext as u}from"../../../../../hooks/pickaxe/useResponseContext.js";const c=()=>{const{deploymentId:c,pickaxe:l,setSender:f,setSenderType:p}=i(),{emailInput:g,redirectUrl:k,isSending:I,isLoggedOut:h,isPricingAuth:w,setToken:j,setIsLoggingIn:v,setIsSending:x,setIsSent:y,setIsResendDisabled:S,setIsPricingAuth:E}=o(),P=r({token:s((null==l?void 0:l.studioid)||"")||"",enabled:h,setIsLoggingIn:v}),{setLimitData:b}=u();t((()=>{if("undefined"==typeof window)return;if(!P.data)return;const{success:e,token:t,error:i}=P.data;if(!e||i)return n(`PXE-token-${null==l?void 0:l.studioid}`),void E(!1);e&&t&&(j(t),f(void 0),p("STUDIO_USER"),w&&(E(!1),b(null)))}),[P.data,null==l?void 0:l.studioid]);return{onSend:t=>e(void 0,void 0,void 0,(function*(){try{if(!l)return;if(I)return;const e=g.trim().toLowerCase();if(!e)throw new Error("Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error("Please enter a valid email address.");if(!l.studioid)throw new Error(`Studio ID is missing for ${l.formid}. Please contact support.`);x(!0),t&&S(!0);const i=(yield a.post("/auth/email",Object.assign(Object.assign({pickaxeId:l.formid,studioId:l.studioid,email:e},c&&{deploymentId:c}),{redirectUrl:k}))).data;if(!i.success)throw new Error(i.error||"Failed to send sign-in link.");x(!1),y(!0),t&&(yield new Promise((e=>setTimeout(e,3e4))),S(!1)),d(`PXE-token-${l.studioid}`,i.token),E(!0)}catch(e){const t=m(e);alert(t)}finally{x(!1)}}))}};export{c as useAuth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";import s from"../../../../common/cn.js";import{useState as i,useRef as a,useEffect as o}from"react";import{Check as r,X as c,MoreHorizontal as l}from"lucide-react";import m from"../../../Icons/trash-2.svg.js";import d from"../../../Icons/pencil.svg.js";const p=({text:e,icon:i,className:a,onClick:o})=>t("div",Object.assign({onClick:e=>{e.stopPropagation(),null==o||o()},className:s("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 transition-all duration-200 cursor-pointer","glass",a),onMouseDown:e=>{e.preventDefault()}},{children:n("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0"},{children:[i&&t("img",{src:i,alt:"",className:"h-5 w-5 shrink-0 rounded-full object-cover"}),t("p",Object.assign({className:"text-xs md:text-sm font-medium truncate max-w-[80px] md:max-w-[150px]"},{children:e}))]}))})),u=({text:p,className:u,onRename:h,onDelete:x,isDarkGlass:g})=>{const[b,f]=i(!1),[w,v]=i(!1),[N,j]=i(p),[k,y]=i(!1),O=a(null),C=a(null);o((()=>{w||j(p)}),[p,w]),o((()=>{const e=e=>{C.current&&!C.current.contains(e.target)&&f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const D=()=>e(void 0,void 0,void 0,(function*(){N.trim()&&(y(!0),yield h(N),y(!1),v(!1))})),E=()=>{j(p),v(!1)};return n("div",Object.assign({ref:C,className:"relative z-40 h-full shrink min-w-0",onMouseDown:e=>{e.preventDefault()}},{children:[t("div",Object.assign({className:s("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 overflow-visible transition-all duration-200 cursor-pointer group","glass",u),onClick:e=>{e.stopPropagation(),w||b?b&&f(!1):f(!0)}},{children:n("div",w?Object.assign({className:"flex items-center gap-2 z-20 min-w-[100px] md:min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[t("input",{autoFocus:!0,type:"text",value:N,onChange:e=>j(e.target.value),onKeyDown:e=>{"Enter"===e.key&&D(),"Escape"===e.key&&E()},className:"bg-transparent border-b border-current text-xs md:text-sm font-medium focus:outline-none w-full min-w-[60px] md:min-w-[80px]",style:{color:"inherit"}}),t("button",Object.assign({onClick:D,disabled:k,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:t(r,{className:"h-4 w-4"})})),t("button",Object.assign({onClick:E,disabled:k,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:t(c,{className:"h-4 w-4"})}))]}):Object.assign({className:"flex items-center gap-2 z-20 min-w-0 max-w-[140px] md:max-w-[200px]"},{children:[t("p",Object.assign({className:"text-xs md:text-sm font-medium truncate"},{children:p})),t(l,{className:s("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity shrink-0")})]}))})),b&&n("div",Object.assign({className:s("absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] overflow-hidden animate-in fade-in zoom-in-95 duration-100",g?"bg-[#313131] text-white":"bg-white text-black"),ref:O},{children:[n("button",Object.assign({onClick:e=>{e.stopPropagation(),f(!1),v(!0)},className:s("w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b hover:opacity-70",g?"border-current":"border-[#EBEAEB]")},{children:[t(d,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),n("button",Object.assign({onClick:e=>{e.stopPropagation(),f(!1),x()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:opacity-70"},{children:[t(m,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))};export{u as EditableNavPill,p as NavPill};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t,useEffect as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as c}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as m}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as f}from"framer-motion";import g from"../../../Icons/lock.svg.js";import x from"../../../Core/ErrorAlert.js";import j from"../../common/PickaxeHead.js";import b from"../../common/PickaxeEmbedHead.js";import v from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import k from"../../common/PickaxeHistoryButton.js";import w from"../../Addons/Scroll/ScrollLockView.js";import N from"../../Addons/Artifact/Renderer/index.js";import O from"./Message.js";import C from"./CustomMessage.js";import S from"../../Addons/IceBreaker/index.js";import A from"../../common/PickaxeBranding.js";import P from"../../../../common/cn.js";const I=({additionalScrollHeight:I,smitheryAuthData:H,isForceHideInfo:L,isInputFocused:R,onSubmit:D,resubmitPrompt:B})=>{var E,
|
|
1
|
+
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t,useEffect as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as c}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as m}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as f}from"framer-motion";import g from"../../../Icons/lock.svg.js";import x from"../../../Core/ErrorAlert.js";import j from"../../common/PickaxeHead.js";import b from"../../common/PickaxeEmbedHead.js";import v from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import k from"../../common/PickaxeHistoryButton.js";import w from"../../Addons/Scroll/ScrollLockView.js";import N from"../../Addons/Artifact/Renderer/index.js";import O from"./Message.js";import C from"./CustomMessage.js";import S from"../../Addons/IceBreaker/index.js";import A from"../../common/PickaxeBranding.js";import P from"../../../../common/cn.js";const I=({additionalScrollHeight:I,smitheryAuthData:H,isForceHideInfo:L,isInputFocused:R,onSubmit:D,resubmitPrompt:B})=>{var T,E,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isShowIceBreaker:K,setSessionId:Q,setLastSessionId:X}=o(),{emailInput:Y,isLoggedOut:Z,isSending:ee,isResendDisabled:se,isSent:ie,isPricingAuth:te}=n(),{onSend:ae}=l(),{scrollContainerRef:oe}=m(),{messages:ne,limitData:le,error:re}=r(),{height:ce,width:me}=c(),{currentArtifact:de,chatPopupType:pe,currentPopupType:ue}=u(),he=p(),fe=d(),ge=t((()=>(null==q?void 0:q.icebreakers)?q.icebreakers.slice(0,3):[]),[null==q?void 0:q.icebreakers]),xe=t((()=>{const e=!!he.data&&he.data.messages.length>1;return!L&&he.isSuccess&&_&&!e}),[L,he.isSuccess,_,he.data]),je=t((()=>!(null==q?void 0:q.chatflag)&&(null==q?void 0:q.enablechatresponses)&&ne.length>0),[q,ne]),be=t((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),ve="chat-input"===$&&te&&Z&&ie,ye=K&&!R&&!be&&xe&&me>767,ke=K&&!R&&(be||me<=767),we=()=>{X(W),Q("")};return a((()=>{oe.current&&requestAnimationFrame((()=>{oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)}))}),[I,oe]),e("div",Object.assign({ref:oe,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[s(h,{children:!!de&&"inline"===ue&&s(f.div,Object.assign({className:P("absolute top-0 z-20 w-full px-4 py-2",pe),style:{height:`calc(${ce-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(N,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[xe&&J&&s("div",Object.assign({className:P("absolute right-4 top-3 flex items-center gap-2","popup"===$&&"right-12")},{children:s(k,{tip:(null==U?void 0:U["chat-history"])||"Chat History",onClick:we})})),s(j,Object.assign({className:P("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",xe&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),J&&!he.isLoading&&s(b,Object.assign({className:P("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!xe&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==U?void 0:U["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e("div",Object.assign({className:P("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",J&&!he.isLoading&&!xe&&"mt-0")},{children:[ye&&s("div",Object.assign({className:P("grid grid-cols-3 gap-4",2===ge.length&&"grid-cols-2",1===ge.length&&"grid-cols-1")},{children:s(S,{type:"center",data:ge,onSend:D})})),ve?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(C,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(g,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Y}))]}))})),s(C,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==U?void 0:U["we-sent-your-an-activation-link"])&&void 0!==F?F:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{se||ee||ae(!0)}},{children:ee?null!==(z=null==U?void 0:U.resending)&&void 0!==z?z:"Resending...":null!==(M=null==U?void 0:U.resend)&&void 0!==M?M:"Resend"}))]}))}))]}))})):s(i,{children:he.isLoading&&!(null==q?void 0:q.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(y,{className:"w-[72px] h-[72px]"}),s(y,{className:"h-[20px] mt-6 w-full"}),s(y,{className:"h-[20px] mt-2 w-full"}),s(y,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(y,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(y,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(y,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:P(fe.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):he.data||je?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(E=null===(T=he.data)||void 0===T?void 0:T.messages)&&void 0!==E?E:[]).map(((e,i)=>s(O,{index:i,message:e},i))),ne.map(((e,i)=>{var t,a;return s(O,{smitheryData:H,resubmitPrompt:B,index:(null!==(a=null===(t=he.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:e,isLastMessage:i===ne.length-1},i)})),le?s("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:s(v,{})})):re?s("div",Object.assign({className:P("flex items-center gap-x-3",G?"justify-end":"justify-start")},{children:s(x,{error:re})})):null]})),e("div",Object.assign({className:P("flex flex-col",!V.isWhiteLabel||ke&&"mt-4")},{children:[!V.isWhiteLabel&&s(A,{containerClassName:P("justify-end",ke&&"mb-2")}),ke&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(S,{type:"right",data:ge,onSend:D})})),s(w,{})]}))]})):null})]}))]}))]}))};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as h}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as x}from"../Addons/Document/hooks/useDocument.js";import{useScroll as j}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as w}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as O}from"../../../hooks/core/useHover.js";import{useMediaQuery as k}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as N,additionalAllowedFileExtensions as I}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import _ from"../../Icons/arrow-right.svg.js";import A from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import P from"../Addons/Document/List.js";import R from"../../Core/Textarea.js";import D from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";const W=i((({resubmitPrompt:i,onFocus:W,onBlur:B,onInputHeightChange:H,initSmitheryAuthData:F},J)=>{var U,M,V;const{origin:K,pickaxeId:X,sessionId:z,sender:q,senderType:G,deploymentId:Q,deploymentType:Y,pickaxe:Z,styles:ee,colors:te,locale:ne,forceMobile:se,isNewChat:oe,isRtl:ie,isEmailLogin:re,isShowFeedbackMessage:ae,setIsNewChat:le,setIsShowIceBreaker:ce,onGenerateComplete:de}=p(),{token:ue,isLoggedOut:me,isSent:pe}=y(),{messages:fe,limits:he,isGenerating:ge,setMessages:ve,setStatus:be,setLimitData:ye,setError:xe}=f(),{documents:je,isUploading:we,documentError:Oe,onFileUpload:ke,setDocuments:Se,setDocumentError:Ne}=x(),{scrollStartSession:Ie,scrollEndSession:Ce,scrollToBottom:Ee}=j({auto:!0}),{artifacts:_e,currentPopupType:Ae,setArtifacts:Te,setCurrentArtifact:Pe}=w(),{height:Re}=b(),De=v(),[Le,$e]=r(""),[We,Be]=r(!1),[He,Fe]=r(!1),Je=a(null),Ue=a(""),Me=a(null),Ve=a(null),Ke=a(null),Xe=a(null),ze=a(null),qe=Math.max(.4*Re,100),{transcript:Ge,listening:Qe,resetTranscript:Ye,browserSupportsSpeechRecognition:Ze}=m(),[et]=k("(max-width: 480px)"),tt=O(),{isHover:nt}=tt,st=e(tt,["isHover"]),ot=O(),{isHover:it}=ot,rt=e(ot,["isHover"]),at=O(),{isHover:lt}=at,ct=e(at,["isHover"]),dt=g(),ut=h(),mt="undefined"!=typeof window?window.location.hostname:"",pt="undefined"!=typeof window?window.location.href:"",ft="undefined"!=typeof window&&window.self!==window.top,ht=mt.includes("pickaxe.co")&&!pt.includes("https://studio.pickaxe.co/_embed")&&!ft,gt=null===(U=null==Z?void 0:Z.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),vt=Ze&&(null==Z?void 0:Z.enablevoicetotext),bt="chat-input"===Y&&oe&&!pe,yt="chat-input"===Y&&re&&me&&pe,xt=null!==(M=null==Z?void 0:Z.placeholdertext)&&void 0!==M?M:ie?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",jt=We||He,wt=l((()=>{var e,t,n;return!!oe&&(!!Z&&(!De.isLoading&&(!((null!==(t=null===(e=De.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Z.icebreakers)||void 0===n?void 0:n.length)&&(!ae&&!bt)))))}),[Z,oe,ae,bt,De.data,De.isLoading]),Ot=l((()=>{if(ge||we)return!1;const e=je.length>0&&je.every((e=>"finished"===e.status));return!(!Le.trim()&&!e)&&je.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ge,we,Le,je]);c(J,(()=>({onSubmit:kt}))),d((()=>{ce(wt)}),[wt]),d((()=>{var e;if(i){const t=Array.from(fe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;kt(n,!0)}}),[i]),d((()=>{if(!Xe.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(Xe.current),()=>{e.disconnect()}}),[H]),d((()=>{if(!Qe)return;const e=Ue.current?`${Ue.current} `:"";$e(`${e}${Ge}`)}),[Ge,Qe]),d((()=>{if(!Ve.current)return;(()=>{if(!Ve.current)return;let e=Ve.current.scrollHeight>52;Le.includes("\n")||je.length?e=!0:Le.trim()||(e=!1),Be(e)})()}),[Le,je]),d((()=>{const e=Ve.current,t=Ke.current;if(!e||!t||We||Le.includes("\n"))return void Fe(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=Le||xt,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Fe(i>l)}),[Le,We,xt]);const kt=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(ge||we)return;const i=je.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:Le;if(!c&&!l)return;xe(""),Ne(""),ye(null),$e(""),le(!1),be("fetching"),Ie(),Ee();const d=null!==(s=null===(t=null==Z?void 0:Z.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,u=[...n?Array.from(fe.slice(0,fe.length-1)):Array.from(fe),...n?[]:[{id:fe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:fe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];ve(u),Ee(),d&&Se([]);const m=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:K,pickaxeId:X,sessionId:z,senderType:G,value:c},d&&{documentIds:r}),q&&{sender:q}),ue&&{studioSessionToken:ue}),Q&&{deploymentId:Q}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},ht&&{credentials:"include"})),p=yield m.json();if(!p.success)throw new Error(p.error||"Failed to start generation");const f=p.submissionId;be("streaming"),ze.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=_e?_e:[]],b=0,y=!1,x="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=ze.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Me.current=t;const n=new TextDecoder,s=C({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return xe(t),void(y=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&F){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw y=!0,F({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,F({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)x="",g.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("text-end"===s.type)x="";else if("reasoning-start"===s.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("reasoning-end"===s.type)x="";else if(s.type.startsWith("data-")){const e=s;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ve([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:fe.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te([...v]),Ae.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Te(v),Ae.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te(v),Ae.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),Te(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Te(v.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);xe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==de||de(z)}catch(e){let t=L(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const n=Object.entries(he).find((([e])=>t.includes(e)));n?ye(n[1]):xe(t)}finally{Ee(),be("idle"),Ce(),Me.current=null}}));return yt?null:n("div",Object.assign({className:$("flex w-full flex-shrink-0 flex-col items-center",!bt&&"px-4 pb-8"),dir:ie?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:Xe,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ee.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ut),{maxHeight:`${qe}px`,overflowY:"auto"})},{children:[Qe&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(V=te.accent)&&void 0!==V?V:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:te.text+"90"}},{children:"Listening..."}))]})),!ge&&je.length>0&&n(P,{className:"p-4 pb-0",isDisabled:ge}),n(R,Object.assign({ref:Ve,className:$(dt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Le.trim()&&!Le.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ie?"text-right":"text-left",jt&&"mb-12",Qe&&"text-transparent"),value:Le,placeholder:xt,onChange:e=>{if($e(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{se||et||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),we||ge||kt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),le(!1),yield ke(t))}))},W&&{onFocus:W},B&&{onBlur:B},{dir:ie?"rtl":"ltr"})),n("div",Object.assign({ref:Ke,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",jt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!jt&&ut.backgroundColor&&{backgroundColor:ut.backgroundColor}),{borderTopRightRadius:ee.cornerRadius+"px",borderBottomRightRadius:ee.cornerRadius+"px"})},{children:ge?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{ze.current&&(ze.current.abort(),ze.current=null),Me.current&&(Me.current.cancel(),Me.current=null),be("idle")},style:{backgroundColor:te.accent,color:te.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):Qe?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:te.accent,color:te.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[gt&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:it?te.accent+"10":void 0,color:it?te.accent:te.accent+"80"},disabled:we||ge,onClick:()=>{var e;return null===(e=Je.current)||void 0===e?void 0:e.click()}},rt,{children:[n("input",{id:"file-upload",ref:Je,type:"file",accept:[...S,...N,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){le(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),vt&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Qe?te.accent:lt?te.accent+"10":void 0,color:Qe?te.accentText:lt?te.accent:te.accent+"80"},disabled:we||ge,onClick:()=>{Qe?u.stopListening():(Ue.current=Le,Ye(),u.startListening({continuous:!0,interimResults:!0,language:ne||"en-US"}))}},ct,{children:n(A,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||Ot?te.accent:te.accent+"10",color:nt||Ot?te.accentText:te.accent+"80"},disabled:!Ot,onClick:()=>kt()},st,{children:n(_,{className:$("h-6 w-6 shrink-0",ie&&"scale-x-[-1] transform")})}))]})}))]})),Oe&&n(D,{error:Oe,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useCallback as l,useEffect as c,useMemo as d,useImperativeHandle as u}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import p,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as f}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as h}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as g}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as v}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as b}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as y}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as x}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as w}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as O}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{useMediaQuery as N}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as C,additionalAllowedFileExtensions as I}from"../../../common/documents.js";import{createParser as _}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import T from"../../Icons/arrow-right.svg.js";import A from"../../Icons/microphone.svg.js";import P from"../../Icons/stop.svg.js";import R from"../Addons/Document/List.js";import D from"../../Core/Textarea.js";import L from"../../Core/ErrorAlert.js";import U from"../../../common/error.js";import $ from"../../../common/cn.js";import{isInIframe as B,initializeEmbedUserId as X}from"../../../common/utils.js";import{useStudio as K}from"../../../hooks/studio/useStudio.js";const W=i((({resubmitPrompt:i,onFocus:W,onBlur:F,onInputHeightChange:H,initSmitheryAuthData:J},M)=>{var V,z,q;const{origin:G,pickaxeId:Q,sessionId:Y,sender:Z,senderType:ee,portalId:te,deploymentId:ne,deploymentType:se,pickaxe:oe,styles:ie,colors:re,locale:ae,forceMobile:le,isNewChat:ce,isRtl:de,isShowFeedbackMessage:ue,accessGroup:pe,setIsNewChat:me,setIsShowIceBreaker:fe,onGenerateComplete:he}=f(),{token:ge,isLoggedOut:ve,isSent:be,isPricingAuth:ye}=x(),{messages:xe,isGenerating:je,setMessages:we,setStatus:Oe,setLimitData:ke,setError:Ne}=h(),{documents:Se,isUploading:Ce,documentError:Ie,onFileUpload:_e,setDocuments:Ee,setDocumentError:Te}=j(),{studio:Ae}=K(),{scrollStartSession:Pe,scrollEndSession:Re,scrollToBottom:De}=w({auto:!0}),{artifacts:Le,currentPopupType:Ue,setArtifacts:$e,setCurrentArtifact:Be}=O(),{height:Xe}=y(),Ke=b(),[We,Fe]=r(""),[He,Je]=r(!1),[Me,Ve]=r(!1),[ze,qe]=r(null),[Ge,Qe]=r(null),[Ye,Ze]=r(!1),et=a(null),tt=a(""),nt=a(null),st=a(null),ot=a(null),it=a(null),rt=a(null),at=Math.max(.4*Xe,100),{transcript:lt,listening:ct,resetTranscript:dt,browserSupportsSpeechRecognition:ut}=m(),[pt]=N("(max-width: 480px)"),mt=k(),{isHover:ft}=mt,ht=e(mt,["isHover"]),gt=k(),{isHover:vt}=gt,bt=e(gt,["isHover"]),yt=k(),{isHover:xt}=yt,jt=e(yt,["isHover"]),wt=v(),Ot=g(),kt="undefined"!=typeof window?window.location.hostname:"",Nt="undefined"!=typeof window?window.location.href:"",St="undefined"!=typeof window&&window.self!==window.top,Ct=kt.includes("pickaxe.co")&&!Nt.includes("https://studio.pickaxe.co/_embed")&&!St,It=null===(V=null==oe?void 0:oe.documentuploadtype)||void 0===V?void 0:V.startsWith("enduserupload"),_t=ut&&(null==oe?void 0:oe.enablevoicetotext),Et="chat-input"===se&&ce&&!be,Tt="chat-input"===se&&ye&&ve&&be,At=null!==(z=null==oe?void 0:oe.placeholdertext)&&void 0!==z?z:de?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",Pt=He||Me,Rt=l((()=>t(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==oe?void 0:oe.studioid},Z&&{sender:Z}),ge&&{studioSessionToken:ge}),!ge&&!Z&&{sender:X()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Ct&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(qe(t.studioUser),Qe(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[G,Q,Y,ee,Z,ge,te,ne,Ct]);c((()=>{Rt()}),[Rt]);const Dt=(null==pe?void 0:pe.limit)||0,Lt=(null==ze?void 0:ze.currentUses)||0,Ut=(null==ze?void 0:ze.extraUses)||0,$t=!!(null==Ae?void 0:Ae.data.usage)&&Ae.data.usage.isCredits,Bt=Dt>Lt?Dt-Lt+Ut:Ut,Xt=d((()=>!!ze&&(!Ye&&(!(Dt<=0)&&Bt<=.05*Dt))),[ze,Ye,Bt,Dt]),Kt=d((()=>{var e,t,n;return!!ce&&(!!oe&&(!Ke.isLoading&&(!((null!==(t=null===(e=Ke.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=oe.icebreakers)||void 0===n?void 0:n.length)&&(!ue&&!Et)))))}),[oe,ce,ue,Et,Ke.data,Ke.isLoading]),Wt=d((()=>{if(je||Ce)return!1;const e=Se.length>0&&Se.every((e=>"finished"===e.status));return!(!We.trim()&&!e)&&Se.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[je,Ce,We,Se]);u(M,(()=>({onSubmit:Ft}))),c((()=>{fe(Kt)}),[Kt]),c((()=>{var e;if(i){const t=Array.from(xe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Ft(n,!0)}}),[i]),c((()=>{if(!it.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(it.current),()=>{e.disconnect()}}),[H]),c((()=>{if(!ct)return;const e=tt.current?`${tt.current} `:"";Fe(`${e}${lt}`)}),[lt,ct]),c((()=>{if(!st.current)return;(()=>{if(!st.current)return;let e=st.current.scrollHeight>52;We.includes("\n")||Se.length?e=!0:We.trim()||(e=!1),Je(e)})()}),[We,Se]),c((()=>{const e=st.current,t=ot.current;if(!e||!t||He||We.includes("\n"))return void Ve(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=We||At,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Ve(i>l)}),[We,He,At]);const Ft=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(je||Ce)return;const i=Se.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:We;if(!c&&!l)return;Ne(""),Te(""),ke(null),Fe(""),me(!1),Oe("fetching"),Pe(),De();const d=null!==(s=null===(t=null==oe?void 0:oe.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,u=[...n?Array.from(xe.slice(0,xe.length-1)):Array.from(xe),...n?[]:[{id:xe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:xe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];we(u),De(),d&&Ee([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:G,pickaxeId:Q,sessionId:Y,senderType:ee,value:c},d&&{documentIds:r}),Z&&{sender:Z}),ge&&{studioSessionToken:ge}),!ge&&!Z&&{sender:X()}),te&&{portalId:te}),ne&&{deploymentId:ne}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},Ct&&{credentials:"include"})),m=yield p.json();if(!m.success){const e=new Error(m.error||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Oe("streaming"),rt.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=Le?Le:[]],b=0,y=!1,x="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=rt.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();nt.current=t;const n=new TextDecoder,s=_({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return Ne(t),void(y=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&J){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw y=!0,J({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,J({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)x="",g.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("text-end"===s.type)x="";else if("reasoning-start"===s.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("reasoning-end"===s.type)x="";else if(s.type.startsWith("data-")){const e=s;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}we([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:xe.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),$e([...v]),Ue.startsWith("inline")||Be({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),$e(v),Ue.startsWith("inline")||Be({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),$e(v),Ue.startsWith("inline")||Be({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),$e(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);$e(v.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);Ne(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==he||he(Y)}catch(e){if(e.limitData)ke(e.limitData),Ne("");else{let t=U(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),Ne(t)}}finally{De(),Oe("idle"),Re(),nt.current=null,yield Rt()}}));return Tt?null:n("div",Object.assign({className:$("flex w-full flex-shrink-0 flex-col items-center",!Et&&"px-4 pb-8"),dir:de?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:it,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ie.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Ot),{maxHeight:`${at}px`,overflowY:"auto"})},{children:[Xt&&s("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Ot.backgroundColor?`${Ot.backgroundColor}E6`:void 0,borderColor:re.text+"20",color:re.text,borderTopRightRadius:ie.cornerRadius+"px",borderTopLeftRadius:ie.cornerRadius+"px"}},{children:[n("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:s("span",{children:[Bt," ",$t?"credits":"uses"," remaining"]})})),s("div",Object.assign({className:"flex items-center gap-3"},{children:[n("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:re.accent,color:re.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Ge}${null==pe?void 0:pe.accessGroupId}`;B()?window.open(t):location.href=t}},{children:"Upgrade"})),n("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Ze(!0)},{children:n("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!je&&Se.length>0&&n(R,{className:"p-4 pb-0",isDisabled:je}),s("div",Object.assign({className:"relative flex w-full flex-col"},{children:[ct&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(q=re.accent)&&void 0!==q?q:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:re.text+"90"}},{children:"Listening..."}))]})),n(D,Object.assign({ref:st,className:$(wt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!We.trim()&&!We.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",de?"text-right":"text-left",Pt&&"mb-12",ct&&"text-transparent"),value:We,placeholder:At,onChange:e=>{if(Fe(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{le||pt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Ce||je||Ft()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),me(!1),yield _e(t))}))},W&&{onFocus:W},F&&{onBlur:F},{dir:de?"rtl":"ltr"})),n("div",Object.assign({ref:ot,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Pt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Pt&&Ot.backgroundColor&&{backgroundColor:Ot.backgroundColor}),{borderTopRightRadius:ie.cornerRadius+"px",borderBottomRightRadius:ie.cornerRadius+"px"})},{children:je?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{rt.current&&(rt.current.abort(),rt.current=null),nt.current&&(nt.current.cancel(),nt.current=null),Oe("idle")},style:{backgroundColor:re.accent,color:re.accentText}},{children:n(P,{className:"h-4 w-4 shrink-0"})})):ct?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:p.stopListening,style:{backgroundColor:re.accent,color:re.accentText}},{children:n(P,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[It&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:vt?re.accent+"10":void 0,color:vt?re.accent:re.accent+"80"},disabled:Ce||je,onClick:()=>{var e;return null===(e=et.current)||void 0===e?void 0:e.click()}},bt,{children:[n("input",{id:"file-upload",ref:et,type:"file",accept:[...S,...C,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){me(!1),yield _e(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),_t&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:ct?re.accent:xt?re.accent+"10":void 0,color:ct?re.accentText:xt?re.accent:re.accent+"80"},disabled:Ce||je,onClick:()=>{ct?p.stopListening():(tt.current=We,dt(),p.startListening({continuous:!0,interimResults:!0,language:ae||"en-US"}))}},jt,{children:n(A,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ft||Wt?re.accent:re.accent+"10",color:ft||Wt?re.accentText:re.accent+"80"},disabled:!Wt,onClick:()=>Ft()},ht,{children:n(T,{className:$("h-6 w-6 shrink-0",de&&"scale-x-[-1] transform")})}))]})}))]}))]})),Ie&&n(L,{error:Ie,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as r,useRef as n,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useStyleFontSize as u}from"../../../hooks/studio/useStyleFontSize.js";import p from"./History/index.js";import f from"./Input.js";import h from"../../Icons/attach-vertical.svg.js";import v from"../../../common/cn.js";import x from"../../../common/api/pickaxe.js";import{v4 as g}from"uuid";import{useResponseContext as b}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as k,EditableNavPill as j}from"../Addons/Navbar/NavPill.js";const y=()=>{const{deploymentType:y,isNewChat:w,setIsNewChat:I,sessionId:D,setSessionId:N,setLastSessionId:C,pickaxeId:A,sender:F,pickaxe:P,styles:S,isEmbed:T}=l(),{isSent:O}=c(),{width:_,height:z,setDimension:E}=d(),{setDocuments:H,onFileUpload:R}=m(),{isGenerating:G,messages:L}=b(),B=u(),[U,q]=r(0),[J,K]=r(!1),[M,Q]=r(!1),V=n(null),W=n(null),X=n(0),[Y,Z]=r(null),[$,ee]=r(!1),te="chat-input"===y&&w&&!O;s((()=>()=>{H([])}),[]);const oe=a((()=>{if(!A||!F)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield x.post("/get_pickaxe_conversation",{sessionId:D,userId:F});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void re(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[A,F,D]);s((()=>{G||w||!D||oe()}),[G,w,D,oe]),s((()=>{if(!V.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;E(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(V.current),()=>{e.disconnect()}}),[V.current]);const[ie,re]=r("New Chat"),ne=(null==P?void 0:P.formtitle)||"Pickaxe",se=(null==P?void 0:P.coverphoto)||void 0,[ae,le]=r(!1);s((()=>{const e=!te&&!T&&S.portalTheme&&(L.filter((e=>"user"===e.role)).length>0||J||!w);le(null!=e&&e)}),[L,J,w]);return t("div",Object.assign({ref:V,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),X.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&Q(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),X.current-=1,0===X.current&&Q(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Q(!1),X.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(I(!1),yield R(e))}))},{children:[M&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(h,{className:"h-10 w-10"})})),o("h3",Object.assign({className:v(B.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),o("p",Object.assign({className:v(B.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),te?o(f,{}):t(i,{children:[ae&&t("div",Object.assign({className:v("direct-link"===y?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===S.portalTheme?"glass-dark ":"")},{children:[o(k,{text:ne,icon:se,onClick:()=>{N(""),C(D)}}),w||"New Chat"===ie?o(k,{text:ie}):o(j,{text:ie,sessionId:D,onRename:t=>e(void 0,void 0,void 0,(function*(){if(D)try{yield x.post("/edit_conversation_name",{sessionId:D,name:t,userId:F}),re(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(D&&window.confirm("Are you sure you want to delete this conversation?"))try{yield x.post("/delete_pickaxe_conversation",{sessionId:D,userId:F}),I(!0),N(g()),re("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}})),isDarkGlass:"dark"===S.portalTheme})]})),o(p,{additionalScrollHeight:U,isForceHideInfo:z<=545||_<=350||J,isInputFocused:J,onSubmit:t=>e(void 0,void 0,void 0,(function*(){W.current&&W.current.onSubmit(t)})),smitheryAuthData:Y,resubmitPrompt:()=>{Z(null),ee(!0)}}),o(f,{ref:W,onFocus:()=>K(!0),onBlur:()=>K(!1),onInputHeightChange:q,initSmitheryAuthData:e=>Z(e),resubmitPrompt:$})]})]}))};export{y as default};
|