codicent-app-sdk 0.3.60 → 0.3.63

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.
@@ -114,22 +114,13 @@ export interface AppConfigOptions {
114
114
  FORM_BACKGROUND_IMAGE_URL: undefined | string;
115
115
  AUTO_TRANSLATE: boolean;
116
116
  APP_LOGBOOK_TITLE: undefined | string;
117
+ LOGIN_WELCOME_TEXT: string | undefined;
118
+ LOGIN_HIDE_WELCOME: boolean;
119
+ LOGIN_LOGO_URL: string | undefined;
117
120
  }
118
121
  export declare function getConfigValue<K extends keyof AppConfigOptions>(key: K): AppConfigOptions[K];
119
122
  /**
120
123
  * Initialize the Codicent App SDK with configuration options
121
124
  */
122
125
  export declare function initCodicentApp(options?: Partial<AppConfigOptions>): void;
123
- declare global {
124
- interface Window {
125
- updateCodicentConfig: (config: Record<string, any>) => void;
126
- }
127
- }
128
- /**
129
- * Updates the existing configuration object with new values from the provided `newConfig` object.
130
- * Only properties that already exist on the original `config` object will be updated.
131
- *
132
- * @param newConfig - An object containing configuration properties to update.
133
- */
134
- export declare const updateConfig: (newConfig: Record<string, any>) => void;
135
126
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;;IAKpB,iBAAiB,EAAE,MAAM,CAAM;IAC/B,2BAA2B,EAAE,MAAM,CAAM;IACzC,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,OAAO,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,GAAG,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YAC1C,KAAK,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YACxD,iBAAiB,EAAE,MAAM,CA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id.core.js");class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_API_KEY:"",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIP_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0};const E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);const A=_=>{Object.keys(_).forEach((T=>{E.hasOwnProperty(T)&&(E[T]=_[T])}))};"undefined"!=typeof window&&(window.updateCodicentConfig=A),exports.AppConfig=T,exports.getConfigValue=function(_){return E[_]},exports.initCodicentApp=function(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);_.default.initialize({startOnLoad:!1})},exports.updateConfig=A;
1
+ "use strict";var _=require("../node_modules/mermaid/dist/mermaid.core.js");class O{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const T={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new O,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_API_KEY:"",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIP_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0,LOGIN_WELCOME_TEXT:void 0,LOGIN_HIDE_WELCOME:!1,LOGIN_LOGO_URL:void 0};const E=function(_){return new Proxy(_,{get:(_,O,T)=>Reflect.get(_,O,T)})}(T);exports.AppConfig=O,exports.getConfigValue=function(_){return E[_]},exports.initCodicentApp=function(O={}){for(const[_,E]of Object.entries(O))void 0!==E&&(T[_]=E);_.default.initialize({startOnLoad:!1})};
@@ -1 +1 @@
1
- {"version":3,"file":"useCodicentApp.d.ts","sourceRoot":"","sources":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hooks/useCodicentApp.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAyB,MAAM,UAAU,CAAC;AACpG,OAAyB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAqB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAA2B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIzE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,cAAc,cAAe;IAAE,KAAK,EAAE,qBAAqB,CAAA;CAAE,KAkGnE,gBACN,CAAC"}
@@ -1 +1 @@
1
- "use strict";var e=require("react");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime");var t=require("../utils/appState.js");require("../_virtual/index.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js");var r=require("./useAudioRecorder.js"),a=require("./useAuthState.js"),s=require("./useRealtimeVoiceAI.js"),n=require("./useTools.js"),c=require("../config/index.js");exports.useCodicentApp=({auth0:u})=>{const i=a.default(u),o=e.useRef(t.createAppStateMachine(i.codicentService,(()=>{}))),[l,d]=e.useState(),{service:p,context:f}=o.current,{nickname:m,name:w,error:A,errorType:h,selectedApp:v}=f,k=e.useCallback(((e,t)=>{const r=e.get("file").name;p.uploadFile(r,e).then((e=>{p.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[p]),S=r.useAudioRecorder(k),[q,C]=e.useState(),[j,y]=e.useState(),[g,b]=e.useState(!1),x=e.useMemo((()=>new Audio("./notification.mp3")),[]),E=n.default(p,C,y,x,q,(()=>b(!0))),_=s.default(c.getConfigValue("REALTIME_VOICE_API_KEY")||"",E),[T,I]=e.useState(!1);e.useEffect((()=>{g&&(_?.disconnectConversation(),b(!1))}),[g,_]),e.useEffect((()=>{i.isAuthenticated&&i.user&&i.accessToken&&o.current.updateContext({isAuthenticated:i.isAuthenticated,user:{sub:i.user.sub,email:i.user.email},accessToken:i.accessToken})}),[i.isAuthenticated,i.user,i.accessToken]),e.useEffect((()=>o.current.updateContext({nickname:i.nickname})),[i.nickname]),e.useEffect((()=>{o.current.update();let e=o.current;const t=setInterval((()=>{"hasAccess"===o.current.currentStateName&&e.currentStateName===o.current.currentStateName||(o.current.update(),d(o.current.getCurrentStateName()),e=o.current)}),50);return()=>clearInterval(t)}),[]),e.useEffect((()=>{(async()=>{if("hasAccess"===l&&!T)try{const e=await p.readDataMessages("appconfig");if(e.length>0){const t=e[0].data;"undefined"!=typeof window&&window.updateCodicentConfig&&window.updateCodicentConfig(t)}I(!0)}catch(e){console.warn("Failed to load app config:",e)}})()}),[l,p,T]),e.useEffect((()=>{"hasAccess"!==l&&I(!1)}),[l]);return{audio:S,auth:i,currentStateName:l,stateMachine:o.current,service:p,context:f,state:l,nickname:m,name:w,error:A,errorType:h,fixAppUrl:e=>e.replace("{nickname}",m||"unknown").replace("{token}",encodeURIComponent(i.accessToken||"unknown")).replace("{app}",v||"unknown"),setAnonymous:e=>{o.current.updateContext({isAnonymous:e})},allStates:o.current.allStates,isBusy:()=>o.current.isBusy(),voice:_,html:q,setHtml:C,script:j}};
1
+ "use strict";var e=require("react");require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime");var t=require("../utils/appState.js");require("../_virtual/index.js"),require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js");var r=require("./useAudioRecorder.js"),s=require("./useAuthState.js"),n=require("./useRealtimeVoiceAI.js"),a=require("./useTools.js"),u=require("../config/index.js");exports.useCodicentApp=({auth0:c})=>{const i=s.default(c),o=e.useRef(t.createAppStateMachine(i.codicentService,(()=>{}))),[l,d]=e.useState(),{service:p,context:m}=o.current,{nickname:f,name:v,error:A,errorType:k,selectedApp:h}=m,q=e.useCallback(((e,t)=>{const r=e.get("file").name;p.uploadFile(r,e).then((e=>{p.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[p]),S=r.useAudioRecorder(q),[j,b]=e.useState(),[w,y]=e.useState(),[C,x]=e.useState(!1),_=e.useMemo((()=>new Audio("./notification.mp3")),[]),T=a.default(p,b,y,_,j,(()=>x(!0))),E=n.default(u.getConfigValue("REALTIME_VOICE_API_KEY")||"",T);e.useEffect((()=>{C&&(E?.disconnectConversation(),x(!1))}),[C,E]),e.useEffect((()=>{i.isAuthenticated&&i.user&&i.accessToken&&o.current.updateContext({isAuthenticated:i.isAuthenticated,user:{sub:i.user.sub,email:i.user.email},accessToken:i.accessToken})}),[i.isAuthenticated,i.user,i.accessToken]),e.useEffect((()=>o.current.updateContext({nickname:i.nickname})),[i.nickname]),e.useEffect((()=>{o.current.update();let e=o.current;const t=setInterval((()=>{"hasAccess"===o.current.currentStateName&&e.currentStateName===o.current.currentStateName||(o.current.update(),d(o.current.getCurrentStateName()),e=o.current)}),50);return()=>clearInterval(t)}),[]);return{audio:S,auth:i,currentStateName:l,stateMachine:o.current,service:p,context:m,state:l,nickname:f,name:v,error:A,errorType:k,fixAppUrl:e=>e.replace("{nickname}",f||"unknown").replace("{token}",encodeURIComponent(i.accessToken||"unknown")).replace("{app}",h||"unknown"),setAnonymous:e=>{o.current.updateContext({isAnonymous:e})},allStates:o.current.allStates,isBusy:()=>o.current.isBusy(),voice:E,html:j,setHtml:b,script:w}};
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("./services/codicent.js"),r=require("./components/Markdown.js"),t=require("./components/Textarea.js"),o=require("./components/Button.js"),s=require("./components/Title.js"),a=require("./components/Text.js"),i=require("./components/Spinner.js"),p=require("./components/Label.js"),u=require("./components/Input.js"),n=require("./components/TextHeader.js"),l=require("./components/TypingIndicator.js"),c=require("./components/Prompt.js"),d=require("./components/ChatInput.js"),x=require("./components/CombinedPlaceholderDialog.js"),j=require("./components/ChatMessage.js"),q=require("./components/Header.js"),m=require("./components/VoiceIcon.js"),g=require("./components/AudioIcon.js"),f=require("./components/FileThumbnail.js"),h=require("./components/MessageInput.js"),S=require("./components/UploadFile.js"),C=require("./components/SnapFooter.js"),A=require("./components/Profile.js"),T=require("./components/MessageItem.js"),I=require("./components/Content.js"),b=require("./components/AiInput.js"),v=require("./components/SearchBox.js"),k=require("./components/HtmlView.js"),M=require("./components/Footer.js"),P=require("./components/Page.js"),F=require("./components/UrlProcessor.js"),L=require("./hooks/useStateWithLocalStorage.js"),w=require("./hooks/useAuthState.js"),V=require("./hooks/useChat.js"),y=require("./hooks/useCodicentState.js"),W=require("./hooks/useAudioRecorder.js"),H=require("./hooks/useTools.js"),R=require("./hooks/useRealtimeVoiceAI.js"),B=require("./hooks/useLocalization.js"),_=require("./hooks/useTemplateVariables.js"),D=require("./hooks/useCodicentApp.js"),U=require("./hooks/useAppStyles.js"),z=require("./hooks/useToaster.js"),G=require("./utils/MessageContent.js"),E=require("./utils/theme.js"),J=require("./utils/logging.js"),K=require("./utils/withWakeLock.js"),N=require("./utils/appState.js"),O=require("./_virtual/index.js");require("./lib/wavtools/lib/wav_packer.js"),require("./lib/wavtools/lib/analysis/audio_analysis.js");var Q=require("./lib/wavtools/lib/wav_stream_player.js"),X=require("./lib/wavtools/lib/wav_recorder.js"),Y=require("./utils/device.js"),Z=require("./utils/helpers.js"),$=require("./config/index.js"),ee=require("./pages/AppFrame.js"),re=require("./pages/Snap.js"),te=require("./pages/Search.js"),oe=require("./pages/Login.js"),se=require("./pages/Logout.js"),ae=require("./pages/CrmPage.js"),ie=require("./pages/ImageView.js"),pe=require("./pages/FormInvite.js"),ue=require("./pages/FormAccept.js"),ne=require("./pages/Sales.js");exports.CodicentService=e.CodicentService,exports.Markdown=r.default,exports.Textarea=t.Textarea,exports.Button=o.Button,exports.Title=s.Title,exports.Text=a.Text,exports.Spinner=i.Spinner,exports.Label=p.Label,exports.Input=u.Input,exports.TextHeader=n.default,exports.TypingIndicator=l.default,exports.Prompt=c.default,exports.ChatInput=d.default,exports.CombinedPlaceholderDialog=x.CombinedPlaceholderDialog,exports.ChatMessage=j.default,exports.Header=q.Header,exports.VoiceIcon=m.default,exports.AudioIcon=g.default,exports.FileThumbnail=f.FileThumbnail,exports.MessageInput=h.default,exports.UploadFile=S.default,exports.SnapFooter=C.default,exports.Profile=A.default,exports.MessageItem=T.default,exports.Content=I.default,exports.AiInput=b.default,exports.SearchBox=v.default,exports.HtmlView=k.default,exports.Footer=M.Footer,exports.Page=P.Page,exports.UrlProcessor=F.UrlProcessor,exports.useStateWithLocalStorage=L.default,exports.useAuthState=w.default,exports.useChat=V.useChat,exports.useCodicentState=y.default,exports.useAudioRecorder=W.useAudioRecorder,exports.useTools=H.default,exports.useRealtimeVoiceAI=R.default,exports.useLocalization=B.default,exports.useTemplateVariables=_.useTemplateVariables,exports.useCodicentApp=D.useCodicentApp,exports.useAppStyles=U.default,exports.useToaster=z.default,exports.MessageContent=G.default,exports.generateBrandVariants=E.default,exports.log=J.default,exports.withWakeLock=K.default,exports.AppStateMachine=N.AppStateMachine,exports.createAppStateMachine=N.createAppStateMachine,exports.WavStreamPlayer=Q.WavStreamPlayer,exports.WavRecorder=X.WavRecorder,exports.getGpsLocation=Y.getGpsLocation,exports.isMobileDevice=Y.isMobileDevice,exports.getTimeString=Z.getTimeString,exports.AppConfig=$.AppConfig,exports.getConfigValue=$.getConfigValue,exports.initCodicentApp=$.initCodicentApp,exports.updateConfig=$.updateConfig,exports.AppFrame=ee.default,exports.Snap=re.default,exports.Search=te.default,exports.Login=oe.default,exports.Logout=se.Logout,exports.CrmPage=ae.CrmPage,exports.ImageView=ie.default,exports.FormInvite=pe.default,exports.FormAccept=ue.default,exports.Sales=ne.Sales,exports.StateMachine=O.distExports.StateMachine;
1
+ "use strict";var e=require("./services/codicent.js"),r=require("./components/Markdown.js"),t=require("./components/Textarea.js"),o=require("./components/Button.js"),s=require("./components/Title.js"),a=require("./components/Text.js"),i=require("./components/Spinner.js"),p=require("./components/Label.js"),u=require("./components/Input.js"),n=require("./components/TextHeader.js"),l=require("./components/TypingIndicator.js"),c=require("./components/Prompt.js"),x=require("./components/ChatInput.js"),d=require("./components/CombinedPlaceholderDialog.js"),j=require("./components/ChatMessage.js"),q=require("./components/Header.js"),m=require("./components/VoiceIcon.js"),g=require("./components/AudioIcon.js"),f=require("./components/FileThumbnail.js"),h=require("./components/MessageInput.js"),S=require("./components/UploadFile.js"),C=require("./components/SnapFooter.js"),A=require("./components/Profile.js"),T=require("./components/MessageItem.js"),I=require("./components/Content.js"),b=require("./components/AiInput.js"),v=require("./components/SearchBox.js"),k=require("./components/HtmlView.js"),M=require("./components/Footer.js"),P=require("./components/Page.js"),F=require("./components/UrlProcessor.js"),L=require("./hooks/useStateWithLocalStorage.js"),w=require("./hooks/useAuthState.js"),V=require("./hooks/useChat.js"),y=require("./hooks/useCodicentState.js"),W=require("./hooks/useAudioRecorder.js"),H=require("./hooks/useTools.js"),R=require("./hooks/useRealtimeVoiceAI.js"),B=require("./hooks/useLocalization.js"),_=require("./hooks/useTemplateVariables.js"),D=require("./hooks/useCodicentApp.js"),U=require("./hooks/useAppStyles.js"),z=require("./hooks/useToaster.js"),G=require("./utils/MessageContent.js"),E=require("./utils/theme.js"),J=require("./utils/logging.js"),K=require("./utils/withWakeLock.js"),N=require("./utils/appState.js"),O=require("./_virtual/index.js");require("./lib/wavtools/lib/wav_packer.js"),require("./lib/wavtools/lib/analysis/audio_analysis.js");var Q=require("./lib/wavtools/lib/wav_stream_player.js"),X=require("./lib/wavtools/lib/wav_recorder.js"),Y=require("./utils/device.js"),Z=require("./utils/helpers.js"),$=require("./config/index.js"),ee=require("./pages/AppFrame.js"),re=require("./pages/Snap.js"),te=require("./pages/Search.js"),oe=require("./pages/Login.js"),se=require("./pages/Logout.js"),ae=require("./pages/CrmPage.js"),ie=require("./pages/ImageView.js"),pe=require("./pages/FormInvite.js"),ue=require("./pages/FormAccept.js"),ne=require("./pages/Sales.js");exports.CodicentService=e.CodicentService,exports.Markdown=r.default,exports.Textarea=t.Textarea,exports.Button=o.Button,exports.Title=s.Title,exports.Text=a.Text,exports.Spinner=i.Spinner,exports.Label=p.Label,exports.Input=u.Input,exports.TextHeader=n.default,exports.TypingIndicator=l.default,exports.Prompt=c.default,exports.ChatInput=x.default,exports.CombinedPlaceholderDialog=d.CombinedPlaceholderDialog,exports.ChatMessage=j.default,exports.Header=q.Header,exports.VoiceIcon=m.default,exports.AudioIcon=g.default,exports.FileThumbnail=f.FileThumbnail,exports.MessageInput=h.default,exports.UploadFile=S.default,exports.SnapFooter=C.default,exports.Profile=A.default,exports.MessageItem=T.default,exports.Content=I.default,exports.AiInput=b.default,exports.SearchBox=v.default,exports.HtmlView=k.default,exports.Footer=M.Footer,exports.Page=P.Page,exports.UrlProcessor=F.UrlProcessor,exports.useStateWithLocalStorage=L.default,exports.useAuthState=w.default,exports.useChat=V.useChat,exports.useCodicentState=y.default,exports.useAudioRecorder=W.useAudioRecorder,exports.useTools=H.default,exports.useRealtimeVoiceAI=R.default,exports.useLocalization=B.default,exports.useTemplateVariables=_.useTemplateVariables,exports.useCodicentApp=D.useCodicentApp,exports.useAppStyles=U.default,exports.useToaster=z.default,exports.MessageContent=G.default,exports.generateBrandVariants=E.default,exports.log=J.default,exports.withWakeLock=K.default,exports.AppStateMachine=N.AppStateMachine,exports.createAppStateMachine=N.createAppStateMachine,exports.WavStreamPlayer=Q.WavStreamPlayer,exports.WavRecorder=X.WavRecorder,exports.getGpsLocation=Y.getGpsLocation,exports.isMobileDevice=Y.isMobileDevice,exports.getTimeString=Z.getTimeString,exports.AppConfig=$.AppConfig,exports.getConfigValue=$.getConfigValue,exports.initCodicentApp=$.initCodicentApp,exports.AppFrame=ee.default,exports.Snap=re.default,exports.Search=te.default,exports.Login=oe.default,exports.Logout=se.Logout,exports.CrmPage=ae.CrmPage,exports.ImageView=ie.default,exports.FormInvite=pe.default,exports.FormAccept=ue.default,exports.Sales=ne.Sales,exports.StateMachine=O.distExports.StateMachine;
@@ -1 +1 @@
1
- {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pages/Login.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAA2D,MAAM,UAAU,CAAC;AAuBrG,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAwDhD,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pages/Login.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAiC,MAAM,UAAU,CAAC;AA0B3E,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAyDhD,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react");require("../services/codicent.js"),require("../components/Markdown.js"),require("../components/Textarea.js");var s=require("../components/Button.js"),i=require("../components/Title.js"),n=require("../components/Text.js");require("../components/Spinner.js"),require("../components/TextHeader.js"),require("../components/TypingIndicator.js"),require("../components/Dialog.js"),require("../components/ChatInput.js"),require("../components/CombinedPlaceholderDialog.js"),require("../components/ChatMessage.js"),require("../components/Header.js"),require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var o=require("../config/index.js");require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../components/FileThumbnail.js"),require("../components/MessageInput.js"),require("../components/UploadFile.js"),require("../components/SnapFooter.js"),require("../components/Profile.js"),require("../components/MessageItem.js"),require("../components/Content.js"),require("../components/AiInput.js"),require("../components/SearchBox.js"),require("../components/HtmlView.js"),require("../components/Footer.js"),require("../components/Page.js"),require("./AppFrame.js"),require("./Snap.js"),require("./Search.js"),require("./CrmPage.js"),require("./ImageView.js"),require("./FormInvite.js"),require("./FormAccept.js"),require("./Sales.js"),require("../stores/chatStore.js");var t=require("../hooks/useLocalization.js"),a=require("../hooks/useAppStyles.js"),u=require("../node_modules/@griffel/react/makeStyles.esm.js"),l=require("../node_modules/@griffel/core/mergeClasses.esm.js");const c=u.makeStyles({container:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",backgroundPosition:"calc(50% - 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",gap:"20px",padding:"0 20px"},button:{minWidth:"15rem"}});exports.default=({state:u})=>{const{loginWithRedirect:m}=u.auth,j=c(),p=a.default(),{t:g}=t.default(),q=o.getConfigValue("LOGIN_REDIRECT");return r.useEffect((()=>{q&&m()}),[q]),q?e.jsxs("div",{className:j.container,style:{backgroundImage:`url(${o.getConfigValue("HOME_BACKGROUND_IMAGE_URL")})`},children:[e.jsx(i.Title,{children:`${g("Välkommen till")} ${o.getConfigValue("INDEX_TITLE")}!`}),e.jsx(n.Text,{size:400,children:g("Omdirigerar till inloggning...")})]}):e.jsxs("div",{className:j.container,style:{backgroundImage:`url(${o.getConfigValue("HOME_BACKGROUND_IMAGE_URL")})`},children:[e.jsx(i.Title,{children:`${g("Välkommen till")} ${o.getConfigValue("INDEX_TITLE")}!`}),e.jsx(n.Text,{size:400,children:g("Logga in, eller registrera ett konto, för att komma igång.")}),e.jsx(s.Button,{className:l.mergeClasses(p.button,j.button),size:"large",appearance:"primary",onClick:()=>m(),children:g("Logga in")}),!o.getConfigValue("HIDE_REGISTER_BUTTON")&&e.jsx(s.Button,{className:l.mergeClasses(p.button,j.button),size:"large",appearance:"primary",onClick:()=>m({authorizationParams:{screen_hint:"signup"}}),children:g("Registrera")})]})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react");require("../services/codicent.js"),require("../components/Markdown.js"),require("../components/Textarea.js");var s=require("../components/Button.js"),i=require("../components/Title.js"),n=require("../components/Text.js");require("../components/Spinner.js"),require("../components/TextHeader.js"),require("../components/TypingIndicator.js"),require("../components/Dialog.js"),require("../components/ChatInput.js"),require("../components/CombinedPlaceholderDialog.js"),require("../components/ChatMessage.js"),require("../components/Header.js"),require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var o=require("../config/index.js");require("../lib/wavtools/lib/wav_packer.js"),require("../lib/wavtools/lib/analysis/audio_analysis.js"),require("../lib/wavtools/lib/wav_stream_player.js"),require("../lib/wavtools/lib/wav_recorder.js"),require("../components/FileThumbnail.js"),require("../components/MessageInput.js"),require("../components/UploadFile.js"),require("../components/SnapFooter.js"),require("../components/Profile.js"),require("../components/MessageItem.js"),require("../components/Content.js"),require("../components/AiInput.js"),require("../components/SearchBox.js"),require("../components/HtmlView.js"),require("../components/Footer.js"),require("../components/Page.js"),require("./AppFrame.js"),require("./Snap.js"),require("./Search.js"),require("./CrmPage.js"),require("./ImageView.js"),require("./FormInvite.js"),require("./FormAccept.js"),require("./Sales.js"),require("../stores/chatStore.js");var t=require("../hooks/useLocalization.js"),a=require("../hooks/useAppStyles.js"),u=require("../node_modules/@griffel/react/makeStyles.esm.js"),l=require("../node_modules/@fluentui/react-image/lib/components/Image/Image.js"),c=require("../node_modules/@griffel/core/mergeClasses.esm.js");const m=u.makeStyles({container:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",backgroundPosition:"calc(50% - 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",gap:"20px",padding:"0 20px"},button:{minWidth:"15rem"},image:{maxHeight:"200px"}});exports.default=({state:u})=>{const{loginWithRedirect:g}=u.auth,j=m(),p=a.default(),{t:q}=t.default(),d=o.getConfigValue("LOGIN_REDIRECT");return r.useEffect((()=>{d&&g()}),[d]),d?e.jsxs("div",{className:j.container,style:{backgroundImage:`url(${o.getConfigValue("HOME_BACKGROUND_IMAGE_URL")})`},children:[e.jsx(i.Title,{children:`${q("Välkommen till")} ${o.getConfigValue("INDEX_TITLE")}!`}),e.jsx(n.Text,{size:400,children:q("Omdirigerar till inloggning...")})]}):e.jsxs("div",{className:j.container,style:{backgroundImage:`url(${o.getConfigValue("HOME_BACKGROUND_IMAGE_URL")})`},children:[o.getConfigValue("LOGIN_LOGO_URL")&&e.jsx(l.Image,{src:o.getConfigValue("LOGIN_LOGO_URL"),alt:o.getConfigValue("INDEX_TITLE"),className:j.image}),!o.getConfigValue("LOGIN_HIDE_WELCOME")&&e.jsx(i.Title,{children:`${q("Välkommen till")} ${o.getConfigValue("INDEX_TITLE")}!`}),e.jsx(n.Text,{size:400,children:q(o.getConfigValue("LOGIN_WELCOME_TEXT")||"Logga in, eller registrera ett konto, för att komma igång.")}),e.jsx(s.Button,{className:c.mergeClasses(p.button,j.button),size:"large",appearance:"primary",onClick:()=>g(),children:q("Logga in")}),!o.getConfigValue("HIDE_REGISTER_BUTTON")&&e.jsx(s.Button,{className:c.mergeClasses(p.button,j.button),size:"large",appearance:"primary",onClick:()=>g({authorizationParams:{screen_hint:"signup"}}),children:q("Registrera")})]})};
@@ -1 +1 @@
1
- {"version":3,"file":"appState.d.ts","sourceRoot":"","sources":["../../../src/utils/appState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIhE,MAAM,WAAW,YAAY;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EACL,SAAS,GACT,iBAAiB,GACjB,gBAAgB,GAChB,kBAAkB,GAClB,uBAAuB,GACvB,sBAAsB,GACtB,uBAAuB,GACvB,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,GACrB,kBAAkB,GAClB,0BAA0B,GAC1B,oBAAoB,GACpB,qBAAqB,CAAC;IAC1B,IAAI,CAAC,EAAE;QAC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KAAK,EAAE,MAAM,KAAK,IAAI;IAQ7E,OAAO,CAAC,YAAY;IAoCb,MAAM;IAIb,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,sBAAsB;IA4d9B,IAAI,KAAK,kBAER;IAED,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,OAAO;IAiBR,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAI5C,UAAU,IAAI,QAAQ,CAAC,YAAY,CAAC;IAIpC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC;IAI5C,mBAAmB;IAKnB,MAAM;IASN,cAAc,CAAC,KAAK,EAAE,MAAM;IAK5B,MAAM;CAad;AAGD,eAAO,MAAM,qBAAqB,YAAa,eAAe,iBAAiB,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,oBAErG,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../_virtual/index.js"),e=require("../config/index.js");class i extends t.distExports.StateMachine{constructor(t,e){super(),this.context={isAuthenticated:void 0,hasAccess:!1,error:null,errorType:void 0,apps:[],hasApps:!1,appsLoaded:!1},this.currentStateName="",this.resetContext(),this.service=t,this.onStateChange=e,this.allStates=this.initializeStateMachine()}resetContext(){this.context={isAuthenticated:!1,isRegistered:void 0,hasValidPurchase:void 0,hasAccess:!1,selectedApp:localStorage.getItem("selectedApp")||void 0,error:null,errorType:void 0,accessToken:void 0,nickname:void 0,apps:[],hasApps:!1,appsLoaded:!1},e.getConfigValue("APP_PREFIX")&&this.context.selectedApp&&!this.context.selectedApp.startsWith(e.getConfigValue("APP_PREFIX"))?this.context.selectedApp=void 0:this.context.selectedApp}update(){super.update()}handlePurchase(){window.location.href="./#/purchase"}initializeStateMachine(){const i=new t.distExports.State,n=new t.distExports.State({entering:()=>{this.context.selectedApp&&!this.service.codicent&&(this.service.codicent=this.context.selectedApp)}}),s=new t.distExports.State,o=new t.distExports.State,r=new t.distExports.State({entering:()=>{this.service.findUsername().then((t=>{t?this.service.nicknameExists(t).then((e=>{e?this.updateContext({error:"Användarnamnet finns redan.",errorType:"UsernameExists"}):this.service.registerUser(t,this.context.user.email,this.context.user.sub,this.context.accessToken).then((()=>{this.service.setToken(this.context.accessToken),this.updateContext({nickname:t,isRegistered:!0})})).catch((t=>{console.warn("Failed to register account",t),this.updateContext({error:"Ett fel uppstod vid registrering. Försök igen senare.",errorType:"ErrorRegistering"})}))})).catch((t=>{console.warn("Failed to check username",t),this.updateContext({error:"Ett fel uppstod vid kontroll av användarnamn.",errorType:"ErrorCheckingUsername"})})):this.updateContext({error:"Användarnamn kunde inte hittas.",errorType:"NoUsernameFound"})})).catch((t=>{console.warn("Failed to find username",t),this.updateContext({error:"Ett fel uppstod vid sökning av användarnamn.",errorType:"ErrorFindingUsername"})}))}}),a=new t.distExports.State,c=new t.distExports.State({entering:()=>{this.checkPurchase()}}),d=new t.distExports.State({entering:()=>{this.handlePurchase()}}),h=new t.distExports.State({entering:()=>{this.getApps()}}),p=new t.distExports.State,l=new t.distExports.State,g=new t.distExports.State({}),x=new t.distExports.State,u=new t.distExports.State({entering:()=>{this.context.nickname&&(localStorage.setItem("nickname",this.context.nickname),this.service.getUserInfo(this.context.nickname).then((t=>{const e=t?.name||t?.nickname||"";this.updateContext({name:e})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorLoadingUser"}))))}}),A=new t.distExports.State({entering:()=>{localStorage.removeItem("selectedApp"),localStorage.removeItem("nickname"),localStorage.removeItem("codicent"),sessionStorage.clear(),this.updateContext({isAuthenticated:!1,isRegistered:void 0,apps:[],hasApps:!1,selectedApp:void 0,accessToken:void 0,user:void 0}),setTimeout((()=>{this.current=this.allStates.initial}),1e3)}}),T=new t.distExports.State({entering:()=>{this.service.createApp().then((t=>{t?(this.service.codicent=t,this.updateContext({selectedApp:t,apps:[...this.context.apps||[],{id:t,title:t,logo:""}]})):this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})})).catch((t=>{console.warn("Error creating app",t),this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})}))}}),C=new t.distExports.State({entering:()=>{this.service.loginUser(this.context.user.sub,this.context.accessToken).then((t=>{null===t?this.updateContext({isRegistered:!1}):""===t?this.updateContext({isRegistered:!1,error:"Kunde inte logga in hos Codicent.",errorType:"CodicentLoginFailed"}):(this.service.setToken(this.context.accessToken),this.service.getNickname().then((t=>{t?this.updateContext({isRegistered:!0,nickname:t}):this.updateContext({error:"Kunde inte hitta användarnamn.",errorType:"ErrorFindingUsername"})})).catch((()=>{this.updateContext({error:"Fel vid hämtning av användarnamn.",errorType:"ErrorFindingUsername"})})))})).catch((()=>{this.updateContext({isRegistered:!1,error:"Fel vid inloggning hos Codicent.",errorType:"CodicentLoginError"})}))}}),E=new t.distExports.State({entering:()=>{this.service.setToken(e.getConfigValue("ANONYMOUS_TOKEN")),this.service.codicent=e.getConfigValue("ANONYMOUS_CODICENT")||e.getConfigValue("APP_NAME")||""}});i.addTransition(n,{condition:()=>!0}),n.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),n.addTransition(x,{condition:()=>Boolean(this.context.error)}),n.addTransition(s,{condition:()=>!1===this.context.isAuthenticated}),s.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),s.addTransition(x,{condition:()=>!!this.context.error}),o.addTransition(C,{}),C.addTransition(r,{condition:()=>!1===this.context.isRegistered}),C.addTransition(a,{condition:()=>!0===this.context.isRegistered}),C.addTransition(x,{condition:()=>!!this.context.error}),a.addTransition(u,{condition:()=>!!this.context.nickname}),a.addTransition(x,{condition:()=>!this.context.nickname,action:()=>this.updateContext({error:"Missing nickname after registration",errorType:"ErrorLoadingUser"})}),c.addTransition(d,{condition:()=>!1===this.context.hasValidPurchase}),c.addTransition(h,{condition:()=>!0===this.context.hasValidPurchase}),h.addTransition(x,{condition:()=>!!this.context.error,action:()=>console.log("getting apps -> error")}),h.addTransition(p,{condition:()=>!!e.getConfigValue("APP_NAME")&&this.context.hasApps}),h.addTransition(T,{condition:()=>!e.getConfigValue("APP_NAME")&&this.context.appsLoaded&&0===this.context.apps.length,action:()=>this.updateContext({selectedApp:void 0})}),h.addTransition(p,{condition:()=>!e.getConfigValue("APP_NAME")&&this.context.hasApps&&this.context.apps.length>0}),T.addTransition(p,{condition:()=>!!this.context.selectedApp}),T.addTransition(x,{condition:()=>!!this.context.error}),p.addTransition(g,{condition:()=>!e.getConfigValue("APP_NAME")&&this.context.apps.some((t=>t.id===this.context.selectedApp)),action:()=>{this.service.codicent=this.context.selectedApp||"",localStorage.setItem("selectedApp",this.context.selectedApp||"")}}),p.addTransition(g,{condition:()=>!e.getConfigValue("APP_NAME")&&!this.context.selectedApp,action:()=>{const t=this.context.apps[0].id;this.context.selectedApp!==t&&(this.service.codicent=t,localStorage.setItem("selectedApp",t),this.updateContext({selectedApp:t}))}}),p.addTransition(g,{condition:()=>this.context.apps.some((t=>t.id===e.getConfigValue("APP_NAME"))),action:()=>{const t=e.getConfigValue("APP_NAME");this.context.selectedApp!==t&&(this.service.codicent=t,this.updateContext({selectedApp:t}))}}),p.addTransition(l,{condition:()=>!this.context.apps.some((t=>t.id===this.context.selectedApp||t.id===e.getConfigValue("APP_NAME"))),action:()=>console.log("checking access -> no access",this.context.apps,this.context.selectedApp,e.getConfigValue("APP_NAME"))}),g.addTransition(u,{condition:()=>!!localStorage.getItem("selectedApp")&&localStorage.getItem("selectedApp")!==this.context.selectedApp,action:()=>{this.service.codicent=localStorage.getItem("selectedApp")||"",this.updateContext({selectedApp:localStorage.getItem("selectedApp")||void 0})}}),r.addTransition(a,{condition:()=>!0===this.context.isRegistered}),r.addTransition(x,{condition:()=>!!this.context.error}),d.addTransition(c,{condition:()=>void 0===this.context.hasValidPurchase,action:()=>{window.history.replaceState({},document.title,window.location.pathname),this.checkPurchase()}}),[n,h,c,C,r].forEach((t=>{t.addTransition(x,{condition:()=>this.context.error?.includes("network")||this.context.error?.includes("connectivity")||!1}),t.addTransition(x,{condition:()=>!!this.context.error})})),[o,a,g,l].forEach((t=>{t.addTransition(A,{condition:()=>!1===this.context.isAuthenticated})})),a.addTransition(u,{condition:()=>!this.context.user&&!!this.context.nickname}),u.addTransition(c,{condition:()=>!!this.context.name&&e.getConfigValue("SUBSCRIPTION_NEEDED")}),u.addTransition(h,{condition:()=>!!this.context.name&&!e.getConfigValue("SUBSCRIPTION_NEEDED")}),x.addTransition(c,{condition:()=>!this.context.error&&"ErrorCheckingPurchase"!==this.context.errorType}),x.addTransition(h,{condition:()=>!this.context.error&&"ErrorGettingApps"!==this.context.errorType}),x.addTransition(p,{condition:()=>!this.context.error&&"ErrorCheckingAccess"!==this.context.errorType}),x.addTransition(u,{condition:()=>!this.context.error&&"ErrorLoadingUser"!==this.context.errorType}),x.addTransition(T,{condition:()=>!this.context.error&&"ErrorCreatingApp"!==this.context.errorType}),x.addTransition(C,{condition:()=>!this.context.error&&"CodicentLoginFailed"!==this.context.errorType}),A.addTransition(i,{condition:()=>!this.context.isAuthenticated&&!this.context.accessToken}),[i,g,s,x,A,n,o,a].forEach((t=>{t.addTransition(E,{condition:()=>!0===this.context.isAnonymous&&!!e.getConfigValue("ANONYMOUS_TOKEN")})}));const S={initial:i,authenticating:n,notAuthenticated:s,authenticated:o,checkingCodicentAccess:C,registering:r,registered:a,checkingPurchase:c,needsPurchase:d,gettingApps:h,creatingApp:T,checkingAccess:p,noAccess:l,error:x,loadingUser:u,loggingOut:A,hasAccess:g,anonymous:E};return this.states.push(...Object.values(S)),S}get error(){return this.context.error}checkPurchase(){this.service.checkSubscriptionStatus().then((t=>this.updateContext({hasValidPurchase:"active"===t}))).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorCheckingPurchase"})))}getApps(){this.service.getApps().then((t=>{if(null===t)throw new Error("Failed to fetch apps.");e.getConfigValue("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e.getConfigValue("APP_PREFIX"))))),this.updateContext({apps:t,hasApps:!0,appsLoaded:!0}),this.context.selectedApp&&!t.some((t=>t.id===this.context.selectedApp))&&this.updateContext({selectedApp:void 0})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorGettingApps"})))}setUser(t){this.context.user=t}getContext(){return{...this.context}}updateContext(t){this.context={...this.context,...t}}getCurrentStateName(){const t=Object.entries(this.allStates).find((([t,e])=>e===this.current));return t?t[0]:""}logout(){localStorage.clear(),sessionStorage.clear(),this.resetContext()}setSelectedApp(t){localStorage.setItem("selectedApp",t),this.update()}isBusy(){return this.current===this.allStates.gettingApps||this.current===this.allStates.checkingPurchase||this.current===this.allStates.checkingAccess||this.current===this.allStates.checkingCodicentAccess||this.current===this.allStates.registering||this.current===this.allStates.loadingUser||this.current===this.allStates.creatingApp||this.current===this.allStates.loggingOut}}exports.AppStateMachine=i,exports.createAppStateMachine=(t,e)=>new i(t,e),exports.default=i;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../_virtual/index.js"),e=require("../config/index.js");class i extends t.distExports.StateMachine{constructor(t,e){super(),this.context={isAuthenticated:void 0,hasAccess:!1,error:null,errorType:void 0,apps:[],hasApps:!1,appsLoaded:!1},this.currentStateName="",this.resetContext(),this.service=t,this.onStateChange=e,this.allStates=this.initializeStateMachine()}resetContext(){this.context={isAuthenticated:!1,isRegistered:void 0,hasValidPurchase:void 0,hasAccess:!1,selectedApp:void 0,error:null,errorType:void 0,accessToken:void 0,nickname:void 0,apps:[],hasApps:!1,appsLoaded:!1},e.getConfigValue("APP_NAME")?localStorage.removeItem("selectedApp"):this.context.selectedApp=localStorage.getItem("selectedApp")||void 0,e.getConfigValue("APP_PREFIX")&&this.context.selectedApp&&!this.context.selectedApp.startsWith(e.getConfigValue("APP_PREFIX"))?this.context.selectedApp=void 0:this.context.selectedApp}update(){super.update()}handlePurchase(){window.location.href="./#/purchase"}initializeStateMachine(){const i=new t.distExports.State,n=new t.distExports.State({entering:()=>{this.context.selectedApp&&!this.service.codicent&&(this.service.codicent=this.context.selectedApp)}}),s=new t.distExports.State,o=new t.distExports.State,r=new t.distExports.State({entering:()=>{this.service.findUsername().then((t=>{t?this.service.nicknameExists(t).then((e=>{e?this.updateContext({error:"Användarnamnet finns redan.",errorType:"UsernameExists"}):this.service.registerUser(t,this.context.user.email,this.context.user.sub,this.context.accessToken).then((()=>{this.service.setToken(this.context.accessToken),this.updateContext({nickname:t,isRegistered:!0})})).catch((t=>{console.warn("Failed to register account",t),this.updateContext({error:"Ett fel uppstod vid registrering. Försök igen senare.",errorType:"ErrorRegistering"})}))})).catch((t=>{console.warn("Failed to check username",t),this.updateContext({error:"Ett fel uppstod vid kontroll av användarnamn.",errorType:"ErrorCheckingUsername"})})):this.updateContext({error:"Användarnamn kunde inte hittas.",errorType:"NoUsernameFound"})})).catch((t=>{console.warn("Failed to find username",t),this.updateContext({error:"Ett fel uppstod vid sökning av användarnamn.",errorType:"ErrorFindingUsername"})}))}}),a=new t.distExports.State,c=new t.distExports.State({entering:()=>{this.checkPurchase()}}),d=new t.distExports.State({entering:()=>{this.handlePurchase()}}),h=new t.distExports.State({entering:()=>{this.getApps()}}),p=new t.distExports.State,l=new t.distExports.State,g=new t.distExports.State({}),x=new t.distExports.State,u=new t.distExports.State({entering:()=>{this.context.nickname&&(localStorage.setItem("nickname",this.context.nickname),this.service.getUserInfo(this.context.nickname).then((t=>{const e=t?.name||t?.nickname||"";this.updateContext({name:e})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorLoadingUser"}))))}}),A=new t.distExports.State({entering:()=>{localStorage.removeItem("selectedApp"),localStorage.removeItem("nickname"),localStorage.removeItem("codicent"),sessionStorage.clear(),this.updateContext({isAuthenticated:!1,isRegistered:void 0,apps:[],hasApps:!1,selectedApp:void 0,accessToken:void 0,user:void 0}),setTimeout((()=>{this.current=this.allStates.initial}),1e3)}}),T=new t.distExports.State({entering:()=>{this.service.createApp().then((t=>{t?(this.service.codicent=t,this.updateContext({selectedApp:t,apps:[...this.context.apps||[],{id:t,title:t,logo:""}]})):this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})})).catch((t=>{console.warn("Error creating app",t),this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})}))}}),C=new t.distExports.State({entering:()=>{this.service.loginUser(this.context.user.sub,this.context.accessToken).then((t=>{null===t?this.updateContext({isRegistered:!1}):""===t?this.updateContext({isRegistered:!1,error:"Kunde inte logga in hos Codicent.",errorType:"CodicentLoginFailed"}):(this.service.setToken(this.context.accessToken),this.service.getNickname().then((t=>{t?this.updateContext({isRegistered:!0,nickname:t}):this.updateContext({error:"Kunde inte hitta användarnamn.",errorType:"ErrorFindingUsername"})})).catch((()=>{this.updateContext({error:"Fel vid hämtning av användarnamn.",errorType:"ErrorFindingUsername"})})))})).catch((()=>{this.updateContext({isRegistered:!1,error:"Fel vid inloggning hos Codicent.",errorType:"CodicentLoginError"})}))}}),E=new t.distExports.State({entering:()=>{this.service.setToken(e.getConfigValue("ANONYMOUS_TOKEN")),this.service.codicent=e.getConfigValue("ANONYMOUS_CODICENT")||e.getConfigValue("APP_NAME")||""}});i.addTransition(n,{condition:()=>!0}),n.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),n.addTransition(x,{condition:()=>Boolean(this.context.error)}),n.addTransition(s,{condition:()=>!1===this.context.isAuthenticated}),s.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),s.addTransition(x,{condition:()=>!!this.context.error}),o.addTransition(C,{}),C.addTransition(r,{condition:()=>!1===this.context.isRegistered}),C.addTransition(a,{condition:()=>!0===this.context.isRegistered}),C.addTransition(x,{condition:()=>!!this.context.error}),a.addTransition(u,{condition:()=>!!this.context.nickname}),a.addTransition(x,{condition:()=>!this.context.nickname,action:()=>this.updateContext({error:"Missing nickname after registration",errorType:"ErrorLoadingUser"})}),c.addTransition(d,{condition:()=>!1===this.context.hasValidPurchase}),c.addTransition(h,{condition:()=>!0===this.context.hasValidPurchase}),h.addTransition(x,{condition:()=>!!this.context.error,action:()=>console.log("getting apps -> error")}),h.addTransition(p,{condition:()=>!!e.getConfigValue("APP_NAME")&&this.context.hasApps}),h.addTransition(T,{condition:()=>!e.getConfigValue("APP_NAME")&&this.context.appsLoaded&&0===this.context.apps.length,action:()=>this.updateContext({selectedApp:void 0})}),h.addTransition(p,{condition:()=>!e.getConfigValue("APP_NAME")&&this.context.hasApps&&this.context.apps.length>0}),T.addTransition(p,{condition:()=>!!this.context.selectedApp}),T.addTransition(x,{condition:()=>!!this.context.error}),p.addTransition(g,{condition:()=>!e.getConfigValue("APP_NAME")&&this.context.apps.some((t=>t.id===this.context.selectedApp)),action:()=>{this.service.codicent=this.context.selectedApp||"",localStorage.setItem("selectedApp",this.context.selectedApp||"")}}),p.addTransition(g,{condition:()=>!e.getConfigValue("APP_NAME")&&!this.context.selectedApp,action:()=>{const t=this.context.apps[0].id;this.context.selectedApp!==t&&(this.service.codicent=t,localStorage.setItem("selectedApp",t),this.updateContext({selectedApp:t}))}}),p.addTransition(g,{condition:()=>this.context.apps.some((t=>t.id===e.getConfigValue("APP_NAME"))),action:()=>{const t=e.getConfigValue("APP_NAME");this.context.selectedApp!==t&&(this.service.codicent=t,this.updateContext({selectedApp:t}))}}),p.addTransition(l,{condition:()=>!this.context.apps.some((t=>t.id===this.context.selectedApp||t.id===e.getConfigValue("APP_NAME"))),action:()=>console.log("checking access -> no access",this.context.apps,this.context.selectedApp,e.getConfigValue("APP_NAME"))}),g.addTransition(u,{condition:()=>!!localStorage.getItem("selectedApp")&&localStorage.getItem("selectedApp")!==this.context.selectedApp,action:()=>{this.service.codicent=localStorage.getItem("selectedApp")||"",this.updateContext({selectedApp:localStorage.getItem("selectedApp")||void 0})}}),r.addTransition(a,{condition:()=>!0===this.context.isRegistered}),r.addTransition(x,{condition:()=>!!this.context.error}),d.addTransition(c,{condition:()=>void 0===this.context.hasValidPurchase,action:()=>{window.history.replaceState({},document.title,window.location.pathname),this.checkPurchase()}}),[n,h,c,C,r].forEach((t=>{t.addTransition(x,{condition:()=>this.context.error?.includes("network")||this.context.error?.includes("connectivity")||!1}),t.addTransition(x,{condition:()=>!!this.context.error})})),[o,a,g,l].forEach((t=>{t.addTransition(A,{condition:()=>!1===this.context.isAuthenticated})})),a.addTransition(u,{condition:()=>!this.context.user&&!!this.context.nickname}),u.addTransition(c,{condition:()=>!!this.context.name&&e.getConfigValue("SUBSCRIPTION_NEEDED")}),u.addTransition(h,{condition:()=>!!this.context.name&&!e.getConfigValue("SUBSCRIPTION_NEEDED")}),x.addTransition(c,{condition:()=>!this.context.error&&"ErrorCheckingPurchase"!==this.context.errorType}),x.addTransition(h,{condition:()=>!this.context.error&&"ErrorGettingApps"!==this.context.errorType}),x.addTransition(p,{condition:()=>!this.context.error&&"ErrorCheckingAccess"!==this.context.errorType}),x.addTransition(u,{condition:()=>!this.context.error&&"ErrorLoadingUser"!==this.context.errorType}),x.addTransition(T,{condition:()=>!this.context.error&&"ErrorCreatingApp"!==this.context.errorType}),x.addTransition(C,{condition:()=>!this.context.error&&"CodicentLoginFailed"!==this.context.errorType}),A.addTransition(i,{condition:()=>!this.context.isAuthenticated&&!this.context.accessToken}),[i,g,s,x,A,n,o,a].forEach((t=>{t.addTransition(E,{condition:()=>!0===this.context.isAnonymous&&!!e.getConfigValue("ANONYMOUS_TOKEN")})}));const S={initial:i,authenticating:n,notAuthenticated:s,authenticated:o,checkingCodicentAccess:C,registering:r,registered:a,checkingPurchase:c,needsPurchase:d,gettingApps:h,creatingApp:T,checkingAccess:p,noAccess:l,error:x,loadingUser:u,loggingOut:A,hasAccess:g,anonymous:E};return this.states.push(...Object.values(S)),S}get error(){return this.context.error}checkPurchase(){this.service.checkSubscriptionStatus().then((t=>this.updateContext({hasValidPurchase:"active"===t}))).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorCheckingPurchase"})))}getApps(){this.service.getApps().then((t=>{if(null===t)throw new Error("Failed to fetch apps.");e.getConfigValue("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e.getConfigValue("APP_PREFIX"))))),this.updateContext({apps:t,hasApps:!0,appsLoaded:!0}),this.context.selectedApp&&!t.some((t=>t.id===this.context.selectedApp))&&this.updateContext({selectedApp:void 0})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorGettingApps"})))}setUser(t){this.context.user=t}getContext(){return{...this.context}}updateContext(t){this.context={...this.context,...t}}getCurrentStateName(){const t=Object.entries(this.allStates).find((([t,e])=>e===this.current));return t?t[0]:""}logout(){localStorage.clear(),sessionStorage.clear(),this.resetContext()}setSelectedApp(t){localStorage.setItem("selectedApp",t),this.update()}isBusy(){return this.current===this.allStates.gettingApps||this.current===this.allStates.checkingPurchase||this.current===this.allStates.checkingAccess||this.current===this.allStates.checkingCodicentAccess||this.current===this.allStates.registering||this.current===this.allStates.loadingUser||this.current===this.allStates.creatingApp||this.current===this.allStates.loggingOut}}exports.AppStateMachine=i,exports.createAppStateMachine=(t,e)=>new i(t,e),exports.default=i;
@@ -114,22 +114,13 @@ export interface AppConfigOptions {
114
114
  FORM_BACKGROUND_IMAGE_URL: undefined | string;
115
115
  AUTO_TRANSLATE: boolean;
116
116
  APP_LOGBOOK_TITLE: undefined | string;
117
+ LOGIN_WELCOME_TEXT: string | undefined;
118
+ LOGIN_HIDE_WELCOME: boolean;
119
+ LOGIN_LOGO_URL: string | undefined;
117
120
  }
118
121
  export declare function getConfigValue<K extends keyof AppConfigOptions>(key: K): AppConfigOptions[K];
119
122
  /**
120
123
  * Initialize the Codicent App SDK with configuration options
121
124
  */
122
125
  export declare function initCodicentApp(options?: Partial<AppConfigOptions>): void;
123
- declare global {
124
- interface Window {
125
- updateCodicentConfig: (config: Record<string, any>) => void;
126
- }
127
- }
128
- /**
129
- * Updates the existing configuration object with new values from the provided `newConfig` object.
130
- * Only properties that already exist on the original `config` object will be updated.
131
- *
132
- * @param newConfig - An object containing configuration properties to update.
133
- */
134
- export declare const updateConfig: (newConfig: Record<string, any>) => void;
135
126
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;;IAKpB,iBAAiB,EAAE,MAAM,CAAM;IAC/B,2BAA2B,EAAE,MAAM,CAAM;IACzC,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,OAAO,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,GAAG,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YAC1C,KAAK,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YACxD,iBAAiB,EAAE,MAAM,CAAC;YAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;YACvB,gBAAgB,EAAE,MAAM,CAAC;YACzB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACtB,CAAC;KACH,CAAC;CAyBH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,yBAAyB,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9C,cAAc,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC,UAAU,EAAE,SAAS,CAAC;IACtB,gBAAgB,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,yBAAyB,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9C,qBAAqB,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1C,gBAAgB,EAAE,SAAS,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AAqB,EAAE,OAAO,CAAC;IAC/B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,yBAAyB,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9C,cAAc,EAAE,OAAO,CAAC;IAIxB,iBAAiB,EAAE,SAAS,GAAG,MAAM,CAAC;IACtC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAkHD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAG5F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,QAUtE"}
@@ -1 +1 @@
1
- import _ from"../node_modules/mermaid/dist/mermaid.core.js";class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_API_KEY:"",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIP_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0};const E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);function A(_){return E[_]}function o(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);_.initialize({startOnLoad:!1})}const P=_=>{Object.keys(_).forEach((T=>{E.hasOwnProperty(T)&&(E[T]=_[T])}))};"undefined"!=typeof window&&(window.updateCodicentConfig=P);export{T as AppConfig,A as getConfigValue,o as initCodicentApp,P as updateConfig};
1
+ import _ from"../node_modules/mermaid/dist/mermaid.core.js";class O{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const T={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new O,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_API_KEY:"",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIP_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0,LOGIN_WELCOME_TEXT:void 0,LOGIN_HIDE_WELCOME:!1,LOGIN_LOGO_URL:void 0};const E=function(_){return new Proxy(_,{get:(_,O,T)=>Reflect.get(_,O,T)})}(T);function A(_){return E[_]}function P(O={}){for(const[_,E]of Object.entries(O))void 0!==E&&(T[_]=E);_.initialize({startOnLoad:!1})}export{O as AppConfig,A as getConfigValue,P as initCodicentApp};
@@ -1 +1 @@
1
- {"version":3,"file":"useCodicentApp.d.ts","sourceRoot":"","sources":["../../../src/hooks/useCodicentApp.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAyB,MAAM,UAAU,CAAC;AACpG,OAAyB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAqB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAA2B,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIzE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,E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AM,CAAC;IAClB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IACnC,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,MAAM,OAAO,CAAC;IACtB,KAAK,EAAE,aAAa,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,cAAc,cAAe;IAAE,KAAK,EAAE,qBAAqB,CAAA;CAAE,KAkGnE,gBACN,CAAC"}
@@ -1 +1 @@
1
- import{useRef as e,useState as t,useCallback as n,useMemo as r,useEffect as a}from"react";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import{createAppStateMachine as o}from"../utils/appState.js";import"../_virtual/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import{useAudioRecorder as s}from"./useAudioRecorder.js";import i from"./useAuthState.js";import c from"./useRealtimeVoiceAI.js";import u from"./useTools.js";import{getConfigValue as l}from"../config/index.js";const m=({auth0:m})=>{const p=i(m),d=e(o(p.codicentService,(()=>{}))),[f,w]=t(),{service:h,context:A}=d.current,{nickname:k,name:v,error:j,errorType:y,selectedApp:C}=A,b=n(((e,t)=>{const n=e.get("file").name;h.uploadFile(n,e).then((e=>{h.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[h]),g=s(b),[x,S]=t(),[_,T]=t(),[I,M]=t(!1),N=r((()=>new Audio("./notification.mp3")),[]),E=u(h,S,T,N,x,(()=>M(!0))),R=c(l("REALTIME_VOICE_API_KEY")||"",E),[B,F]=t(!1);a((()=>{I&&(R?.disconnectConversation(),M(!1))}),[I,R]),a((()=>{p.isAuthenticated&&p.user&&p.accessToken&&d.current.updateContext({isAuthenticated:p.isAuthenticated,user:{sub:p.user.sub,email:p.user.email},accessToken:p.accessToken})}),[p.isAuthenticated,p.user,p.accessToken]),a((()=>d.current.updateContext({nickname:p.nickname})),[p.nickname]),a((()=>{d.current.update();let e=d.current;const t=setInterval((()=>{"hasAccess"===d.current.currentStateName&&e.currentStateName===d.current.currentStateName||(d.current.update(),w(d.current.getCurrentStateName()),e=d.current)}),50);return()=>clearInterval(t)}),[]),a((()=>{(async()=>{if("hasAccess"===f&&!B)try{const e=await h.readDataMessages("appconfig");if(e.length>0){const t=e[0].data;"undefined"!=typeof window&&window.updateCodicentConfig&&window.updateCodicentConfig(t)}F(!0)}catch(e){console.warn("Failed to load app config:",e)}})()}),[f,h,B]),a((()=>{"hasAccess"!==f&&F(!1)}),[f]);return{audio:g,auth:p,currentStateName:f,stateMachine:d.current,service:h,context:A,state:f,nickname:k,name:v,error:j,errorType:y,fixAppUrl:e=>e.replace("{nickname}",k||"unknown").replace("{token}",encodeURIComponent(p.accessToken||"unknown")).replace("{app}",C||"unknown"),setAnonymous:e=>{d.current.updateContext({isAnonymous:e})},allStates:d.current.allStates,isBusy:()=>d.current.isBusy(),voice:R,html:x,setHtml:S,script:_}};export{m as useCodicentApp};
1
+ import{useRef as e,useState as t,useCallback as r,useMemo as n,useEffect as s}from"react";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import{createAppStateMachine as o}from"../utils/appState.js";import"../_virtual/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import{useAudioRecorder as a}from"./useAudioRecorder.js";import i from"./useAuthState.js";import c from"./useRealtimeVoiceAI.js";import u from"./useTools.js";import{getConfigValue as m}from"../config/index.js";const l=({auth0:l})=>{const p=i(l),d=e(o(p.codicentService,(()=>{}))),[k,v]=t(),{service:A,context:h}=d.current,{nickname:j,name:f,error:w,errorType:b,selectedApp:y}=h,x=r(((e,t)=>{const r=e.get("file").name;A.uploadFile(r,e).then((e=>{A.sendMessage(`#transcribe ${""!==t?(t.startsWith("#")?"":"#")+t+" ":""}#file:${e}`).then((()=>{})).catch(console.warn)}))}),[A]),S=a(x),[_,T]=t(),[C,I]=t(),[g,N]=t(!1),E=n((()=>new Audio("./notification.mp3")),[]),M=u(A,T,I,E,_,(()=>N(!0))),R=c(m("REALTIME_VOICE_API_KEY")||"",M);s((()=>{g&&(R?.disconnectConversation(),N(!1))}),[g,R]),s((()=>{p.isAuthenticated&&p.user&&p.accessToken&&d.current.updateContext({isAuthenticated:p.isAuthenticated,user:{sub:p.user.sub,email:p.user.email},accessToken:p.accessToken})}),[p.isAuthenticated,p.user,p.accessToken]),s((()=>d.current.updateContext({nickname:p.nickname})),[p.nickname]),s((()=>{d.current.update();let e=d.current;const t=setInterval((()=>{"hasAccess"===d.current.currentStateName&&e.currentStateName===d.current.currentStateName||(d.current.update(),v(d.current.getCurrentStateName()),e=d.current)}),50);return()=>clearInterval(t)}),[]);return{audio:S,auth:p,currentStateName:k,stateMachine:d.current,service:A,context:h,state:k,nickname:j,name:f,error:w,errorType:b,fixAppUrl:e=>e.replace("{nickname}",j||"unknown").replace("{token}",encodeURIComponent(p.accessToken||"unknown")).replace("{app}",y||"unknown"),setAnonymous:e=>{d.current.updateContext({isAnonymous:e})},allStates:d.current.allStates,isBusy:()=>d.current.isBusy(),voice:R,html:_,setHtml:T,script:C}};export{l as useCodicentApp};
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{CodicentService}from"./services/codicent.js";export{default as Markdown}from"./components/Markdown.js";export{Textarea}from"./components/Textarea.js";export{Button}from"./components/Button.js";export{Title}from"./components/Title.js";export{Text}from"./components/Text.js";export{Spinner}from"./components/Spinner.js";export{Label}from"./components/Label.js";export{Input}from"./components/Input.js";export{default as TextHeader}from"./components/TextHeader.js";export{default as TypingIndicator}from"./components/TypingIndicator.js";export{default as Prompt}from"./components/Prompt.js";export{default as ChatInput}from"./components/ChatInput.js";export{CombinedPlaceholderDialog}from"./components/CombinedPlaceholderDialog.js";export{default as ChatMessage}from"./components/ChatMessage.js";export{Header}from"./components/Header.js";export{default as VoiceIcon}from"./components/VoiceIcon.js";export{default as AudioIcon}from"./components/AudioIcon.js";export{FileThumbnail}from"./components/FileThumbnail.js";export{default as MessageInput}from"./components/MessageInput.js";export{default as UploadFile}from"./components/UploadFile.js";export{default as SnapFooter}from"./components/SnapFooter.js";export{default as Profile}from"./components/Profile.js";export{default as MessageItem}from"./components/MessageItem.js";export{default as Content}from"./components/Content.js";export{default as AiInput}from"./components/AiInput.js";export{default as SearchBox}from"./components/SearchBox.js";export{default as HtmlView}from"./components/HtmlView.js";export{Footer}from"./components/Footer.js";export{Page}from"./components/Page.js";export{UrlProcessor}from"./components/UrlProcessor.js";export{default as useStateWithLocalStorage}from"./hooks/useStateWithLocalStorage.js";export{default as useAuthState}from"./hooks/useAuthState.js";export{useChat}from"./hooks/useChat.js";export{default as useCodicentState}from"./hooks/useCodicentState.js";export{useAudioRecorder}from"./hooks/useAudioRecorder.js";export{default as useTools}from"./hooks/useTools.js";export{default as useRealtimeVoiceAI}from"./hooks/useRealtimeVoiceAI.js";export{default as useLocalization}from"./hooks/useLocalization.js";export{useTemplateVariables}from"./hooks/useTemplateVariables.js";export{useCodicentApp}from"./hooks/useCodicentApp.js";export{default as useAppStyles}from"./hooks/useAppStyles.js";export{default as useToaster}from"./hooks/useToaster.js";export{default as MessageContent}from"./utils/MessageContent.js";export{default as generateBrandVariants}from"./utils/theme.js";export{default as log}from"./utils/logging.js";export{default as withWakeLock}from"./utils/withWakeLock.js";export{AppStateMachine,createAppStateMachine}from"./utils/appState.js";import{d as e}from"./_virtual/index.js";import"./lib/wavtools/lib/wav_packer.js";import"./lib/wavtools/lib/analysis/audio_analysis.js";export{WavStreamPlayer}from"./lib/wavtools/lib/wav_stream_player.js";export{WavRecorder}from"./lib/wavtools/lib/wav_recorder.js";export{getGpsLocation,isMobileDevice}from"./utils/device.js";export{getTimeString}from"./utils/helpers.js";export{AppConfig,getConfigValue,initCodicentApp,updateConfig}from"./config/index.js";export{default as AppFrame}from"./pages/AppFrame.js";export{default as Snap}from"./pages/Snap.js";export{default as Search}from"./pages/Search.js";export{default as Login}from"./pages/Login.js";export{Logout}from"./pages/Logout.js";export{CrmPage}from"./pages/CrmPage.js";export{default as ImageView}from"./pages/ImageView.js";export{default as FormInvite}from"./pages/FormInvite.js";export{default as FormAccept}from"./pages/FormAccept.js";export{Sales}from"./pages/Sales.js";var o=e.StateMachine;export{o as StateMachine};
1
+ export{CodicentService}from"./services/codicent.js";export{default as Markdown}from"./components/Markdown.js";export{Textarea}from"./components/Textarea.js";export{Button}from"./components/Button.js";export{Title}from"./components/Title.js";export{Text}from"./components/Text.js";export{Spinner}from"./components/Spinner.js";export{Label}from"./components/Label.js";export{Input}from"./components/Input.js";export{default as TextHeader}from"./components/TextHeader.js";export{default as TypingIndicator}from"./components/TypingIndicator.js";export{default as Prompt}from"./components/Prompt.js";export{default as ChatInput}from"./components/ChatInput.js";export{CombinedPlaceholderDialog}from"./components/CombinedPlaceholderDialog.js";export{default as ChatMessage}from"./components/ChatMessage.js";export{Header}from"./components/Header.js";export{default as VoiceIcon}from"./components/VoiceIcon.js";export{default as AudioIcon}from"./components/AudioIcon.js";export{FileThumbnail}from"./components/FileThumbnail.js";export{default as MessageInput}from"./components/MessageInput.js";export{default as UploadFile}from"./components/UploadFile.js";export{default as SnapFooter}from"./components/SnapFooter.js";export{default as Profile}from"./components/Profile.js";export{default as MessageItem}from"./components/MessageItem.js";export{default as Content}from"./components/Content.js";export{default as AiInput}from"./components/AiInput.js";export{default as SearchBox}from"./components/SearchBox.js";export{default as HtmlView}from"./components/HtmlView.js";export{Footer}from"./components/Footer.js";export{Page}from"./components/Page.js";export{UrlProcessor}from"./components/UrlProcessor.js";export{default as useStateWithLocalStorage}from"./hooks/useStateWithLocalStorage.js";export{default as useAuthState}from"./hooks/useAuthState.js";export{useChat}from"./hooks/useChat.js";export{default as useCodicentState}from"./hooks/useCodicentState.js";export{useAudioRecorder}from"./hooks/useAudioRecorder.js";export{default as useTools}from"./hooks/useTools.js";export{default as useRealtimeVoiceAI}from"./hooks/useRealtimeVoiceAI.js";export{default as useLocalization}from"./hooks/useLocalization.js";export{useTemplateVariables}from"./hooks/useTemplateVariables.js";export{useCodicentApp}from"./hooks/useCodicentApp.js";export{default as useAppStyles}from"./hooks/useAppStyles.js";export{default as useToaster}from"./hooks/useToaster.js";export{default as MessageContent}from"./utils/MessageContent.js";export{default as generateBrandVariants}from"./utils/theme.js";export{default as log}from"./utils/logging.js";export{default as withWakeLock}from"./utils/withWakeLock.js";export{AppStateMachine,createAppStateMachine}from"./utils/appState.js";import{d as e}from"./_virtual/index.js";import"./lib/wavtools/lib/wav_packer.js";import"./lib/wavtools/lib/analysis/audio_analysis.js";export{WavStreamPlayer}from"./lib/wavtools/lib/wav_stream_player.js";export{WavRecorder}from"./lib/wavtools/lib/wav_recorder.js";export{getGpsLocation,isMobileDevice}from"./utils/device.js";export{getTimeString}from"./utils/helpers.js";export{AppConfig,getConfigValue,initCodicentApp}from"./config/index.js";export{default as AppFrame}from"./pages/AppFrame.js";export{default as Snap}from"./pages/Snap.js";export{default as Search}from"./pages/Search.js";export{default as Login}from"./pages/Login.js";export{Logout}from"./pages/Logout.js";export{CrmPage}from"./pages/CrmPage.js";export{default as ImageView}from"./pages/ImageView.js";export{default as FormInvite}from"./pages/FormInvite.js";export{default as FormAccept}from"./pages/FormAccept.js";export{Sales}from"./pages/Sales.js";var o=e.StateMachine;export{o as StateMachine};
@@ -1 +1 @@
1
- {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pages/Login.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAA2D,MAAM,UAAU,CAAC;AAuBrG,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAwDhD,CAAC;AAEF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Login.d.ts","sourceRoot":"","sources":["../../../src/pages/Login.tsx"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAiC,MAAM,UAAU,CAAC;AA0B3E,QAAA,MAAM,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAyDhD,CAAC;AAEF,eAAe,KAAK,CAAC"}
@@ -1 +1 @@
1
- import{jsxs as o,jsx as t}from"react/jsx-runtime";import e from"react";import"../services/codicent.js";import"../components/Markdown.js";import"../components/Textarea.js";import{Button as r}from"../components/Button.js";import{Title as i}from"../components/Title.js";import{Text as n}from"../components/Text.js";import"../components/Spinner.js";import"../components/TextHeader.js";import"../components/TypingIndicator.js";import"../components/Dialog.js";import"../components/ChatInput.js";import"../components/CombinedPlaceholderDialog.js";import"../components/ChatMessage.js";import"../components/Header.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as s}from"../config/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../components/FileThumbnail.js";import"../components/MessageInput.js";import"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/Content.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/Page.js";import"./AppFrame.js";import"./Snap.js";import"./Search.js";import"./CrmPage.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"../stores/chatStore.js";import m from"../hooks/useLocalization.js";import p from"../hooks/useAppStyles.js";import{makeStyles as a}from"../node_modules/@griffel/react/makeStyles.esm.js";import{mergeClasses as c}from"../node_modules/@griffel/core/mergeClasses.esm.js";const l=a({container:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",backgroundPosition:"calc(50% - 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",gap:"20px",padding:"0 20px"},button:{minWidth:"15rem"}}),j=({state:a})=>{const{loginWithRedirect:j}=a.auth,g=l(),d=p(),{t:u}=m(),h=s("LOGIN_REDIRECT");return e.useEffect((()=>{h&&j()}),[h]),o("div",h?{className:g.container,style:{backgroundImage:`url(${s("HOME_BACKGROUND_IMAGE_URL")})`},children:[t(i,{children:`${u("Välkommen till")} ${s("INDEX_TITLE")}!`}),t(n,{size:400,children:u("Omdirigerar till inloggning...")})]}:{className:g.container,style:{backgroundImage:`url(${s("HOME_BACKGROUND_IMAGE_URL")})`},children:[t(i,{children:`${u("Välkommen till")} ${s("INDEX_TITLE")}!`}),t(n,{size:400,children:u("Logga in, eller registrera ett konto, för att komma igång.")}),t(r,{className:c(d.button,g.button),size:"large",appearance:"primary",onClick:()=>j(),children:u("Logga in")}),!s("HIDE_REGISTER_BUTTON")&&t(r,{className:c(d.button,g.button),size:"large",appearance:"primary",onClick:()=>j({authorizationParams:{screen_hint:"signup"}}),children:u("Registrera")})]})};export{j as default};
1
+ import{jsxs as o,jsx as e}from"react/jsx-runtime";import t from"react";import"../services/codicent.js";import"../components/Markdown.js";import"../components/Textarea.js";import{Button as i}from"../components/Button.js";import{Title as r}from"../components/Title.js";import{Text as s}from"../components/Text.js";import"../components/Spinner.js";import"../components/TextHeader.js";import"../components/TypingIndicator.js";import"../components/Dialog.js";import"../components/ChatInput.js";import"../components/CombinedPlaceholderDialog.js";import"../components/ChatMessage.js";import"../components/Header.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as n}from"../config/index.js";import"../lib/wavtools/lib/wav_packer.js";import"../lib/wavtools/lib/analysis/audio_analysis.js";import"../lib/wavtools/lib/wav_stream_player.js";import"../lib/wavtools/lib/wav_recorder.js";import"../components/FileThumbnail.js";import"../components/MessageInput.js";import"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/Content.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/HtmlView.js";import"../components/Footer.js";import"../components/Page.js";import"./AppFrame.js";import"./Snap.js";import"./Search.js";import"./CrmPage.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"../stores/chatStore.js";import m from"../hooks/useLocalization.js";import a from"../hooks/useAppStyles.js";import{makeStyles as p}from"../node_modules/@griffel/react/makeStyles.esm.js";import{Image as c}from"../node_modules/@fluentui/react-image/lib/components/Image/Image.js";import{mergeClasses as l}from"../node_modules/@griffel/core/mergeClasses.esm.js";const j=p({container:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100vh",backgroundPosition:"calc(50% - 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",gap:"20px",padding:"0 20px"},button:{minWidth:"15rem"},image:{maxHeight:"200px"}}),g=({state:p})=>{const{loginWithRedirect:g}=p.auth,d=j(),u=a(),{t:_}=m(),I=n("LOGIN_REDIRECT");return t.useEffect((()=>{I&&g()}),[I]),o("div",I?{className:d.container,style:{backgroundImage:`url(${n("HOME_BACKGROUND_IMAGE_URL")})`},children:[e(r,{children:`${_("Välkommen till")} ${n("INDEX_TITLE")}!`}),e(s,{size:400,children:_("Omdirigerar till inloggning...")})]}:{className:d.container,style:{backgroundImage:`url(${n("HOME_BACKGROUND_IMAGE_URL")})`},children:[n("LOGIN_LOGO_URL")&&e(c,{src:n("LOGIN_LOGO_URL"),alt:n("INDEX_TITLE"),className:d.image}),!n("LOGIN_HIDE_WELCOME")&&e(r,{children:`${_("Välkommen till")} ${n("INDEX_TITLE")}!`}),e(s,{size:400,children:_(n("LOGIN_WELCOME_TEXT")||"Logga in, eller registrera ett konto, för att komma igång.")}),e(i,{className:l(u.button,d.button),size:"large",appearance:"primary",onClick:()=>g(),children:_("Logga in")}),!n("HIDE_REGISTER_BUTTON")&&e(i,{className:l(u.button,d.button),size:"large",appearance:"primary",onClick:()=>g({authorizationParams:{screen_hint:"signup"}}),children:_("Registrera")})]})};export{g as default};
@@ -1 +1 @@
1
- {"version":3,"file":"appState.d.ts","sourceRoot":"","sources":["../../../src/utils/appState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAIhE,MAAM,WAAW,YAAY;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EACL,SAAS,GACT,iBAAiB,GACjB,gBAAgB,GAChB,kBAAkB,GAClB,uBAAuB,GACvB,sBAAsB,GACtB,uBAAuB,GACvB,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,GACrB,kBAAkB,GAClB,0BAA0B,GAC1B,oBAAoB,GACpB,qBAAqB,CAAC;IAC1B,IAAI,CAAC,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC;IACjB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AC,OAAO;IAiBR,OAAO,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE;IAI5C,UAAU,IAAI,QAAQ,CAAC,YAAY,CAAC;IAIpC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC;IAI5C,mBAAmB;IAKnB,MAAM;IASN,cAAc,CAAC,KAAK,EAAE,MAAM;IAK5B,MAAM;CAad;AAGD,eAAO,MAAM,qBAAqB,YAAa,eAAe,iBAAiB,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,oBAErG,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- import{d as t}from"../_virtual/index.js";import{getConfigValue as e}from"../config/index.js";class i extends t.StateMachine{constructor(t,e){super(),this.context={isAuthenticated:void 0,hasAccess:!1,error:null,errorType:void 0,apps:[],hasApps:!1,appsLoaded:!1},this.currentStateName="",this.resetContext(),this.service=t,this.onStateChange=e,this.allStates=this.initializeStateMachine()}resetContext(){this.context={isAuthenticated:!1,isRegistered:void 0,hasValidPurchase:void 0,hasAccess:!1,selectedApp:localStorage.getItem("selectedApp")||void 0,error:null,errorType:void 0,accessToken:void 0,nickname:void 0,apps:[],hasApps:!1,appsLoaded:!1},e("APP_PREFIX")&&this.context.selectedApp&&!this.context.selectedApp.startsWith(e("APP_PREFIX"))?this.context.selectedApp=void 0:this.context.selectedApp}update(){super.update()}handlePurchase(){window.location.href="./#/purchase"}initializeStateMachine(){const i=new t.State,n=new t.State({entering:()=>{this.context.selectedApp&&!this.service.codicent&&(this.service.codicent=this.context.selectedApp)}}),s=new t.State,o=new t.State,r=new t.State({entering:()=>{this.service.findUsername().then((t=>{t?this.service.nicknameExists(t).then((e=>{e?this.updateContext({error:"Användarnamnet finns redan.",errorType:"UsernameExists"}):this.service.registerUser(t,this.context.user.email,this.context.user.sub,this.context.accessToken).then((()=>{this.service.setToken(this.context.accessToken),this.updateContext({nickname:t,isRegistered:!0})})).catch((t=>{console.warn("Failed to register account",t),this.updateContext({error:"Ett fel uppstod vid registrering. Försök igen senare.",errorType:"ErrorRegistering"})}))})).catch((t=>{console.warn("Failed to check username",t),this.updateContext({error:"Ett fel uppstod vid kontroll av användarnamn.",errorType:"ErrorCheckingUsername"})})):this.updateContext({error:"Användarnamn kunde inte hittas.",errorType:"NoUsernameFound"})})).catch((t=>{console.warn("Failed to find username",t),this.updateContext({error:"Ett fel uppstod vid sökning av användarnamn.",errorType:"ErrorFindingUsername"})}))}}),a=new t.State,c=new t.State({entering:()=>{this.checkPurchase()}}),d=new t.State({entering:()=>{this.handlePurchase()}}),h=new t.State({entering:()=>{this.getApps()}}),p=new t.State,l=new t.State,g=new t.State({}),x=new t.State,u=new t.State({entering:()=>{this.context.nickname&&(localStorage.setItem("nickname",this.context.nickname),this.service.getUserInfo(this.context.nickname).then((t=>{const e=t?.name||t?.nickname||"";this.updateContext({name:e})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorLoadingUser"}))))}}),A=new t.State({entering:()=>{localStorage.removeItem("selectedApp"),localStorage.removeItem("nickname"),localStorage.removeItem("codicent"),sessionStorage.clear(),this.updateContext({isAuthenticated:!1,isRegistered:void 0,apps:[],hasApps:!1,selectedApp:void 0,accessToken:void 0,user:void 0}),setTimeout((()=>{this.current=this.allStates.initial}),1e3)}}),T=new t.State({entering:()=>{this.service.createApp().then((t=>{t?(this.service.codicent=t,this.updateContext({selectedApp:t,apps:[...this.context.apps||[],{id:t,title:t,logo:""}]})):this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})})).catch((t=>{console.warn("Error creating app",t),this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})}))}}),m=new t.State({entering:()=>{this.service.loginUser(this.context.user.sub,this.context.accessToken).then((t=>{null===t?this.updateContext({isRegistered:!1}):""===t?this.updateContext({isRegistered:!1,error:"Kunde inte logga in hos Codicent.",errorType:"CodicentLoginFailed"}):(this.service.setToken(this.context.accessToken),this.service.getNickname().then((t=>{t?this.updateContext({isRegistered:!0,nickname:t}):this.updateContext({error:"Kunde inte hitta användarnamn.",errorType:"ErrorFindingUsername"})})).catch((()=>{this.updateContext({error:"Fel vid hämtning av användarnamn.",errorType:"ErrorFindingUsername"})})))})).catch((()=>{this.updateContext({isRegistered:!1,error:"Fel vid inloggning hos Codicent.",errorType:"CodicentLoginError"})}))}}),S=new t.State({entering:()=>{this.service.setToken(e("ANONYMOUS_TOKEN")),this.service.codicent=e("ANONYMOUS_CODICENT")||e("APP_NAME")||""}});i.addTransition(n,{condition:()=>!0}),n.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),n.addTransition(x,{condition:()=>Boolean(this.context.error)}),n.addTransition(s,{condition:()=>!1===this.context.isAuthenticated}),s.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),s.addTransition(x,{condition:()=>!!this.context.error}),o.addTransition(m,{}),m.addTransition(r,{condition:()=>!1===this.context.isRegistered}),m.addTransition(a,{condition:()=>!0===this.context.isRegistered}),m.addTransition(x,{condition:()=>!!this.context.error}),a.addTransition(u,{condition:()=>!!this.context.nickname}),a.addTransition(x,{condition:()=>!this.context.nickname,action:()=>this.updateContext({error:"Missing nickname after registration",errorType:"ErrorLoadingUser"})}),c.addTransition(d,{condition:()=>!1===this.context.hasValidPurchase}),c.addTransition(h,{condition:()=>!0===this.context.hasValidPurchase}),h.addTransition(x,{condition:()=>!!this.context.error,action:()=>console.log("getting apps -> error")}),h.addTransition(p,{condition:()=>!!e("APP_NAME")&&this.context.hasApps}),h.addTransition(T,{condition:()=>!e("APP_NAME")&&this.context.appsLoaded&&0===this.context.apps.length,action:()=>this.updateContext({selectedApp:void 0})}),h.addTransition(p,{condition:()=>!e("APP_NAME")&&this.context.hasApps&&this.context.apps.length>0}),T.addTransition(p,{condition:()=>!!this.context.selectedApp}),T.addTransition(x,{condition:()=>!!this.context.error}),p.addTransition(g,{condition:()=>!e("APP_NAME")&&this.context.apps.some((t=>t.id===this.context.selectedApp)),action:()=>{this.service.codicent=this.context.selectedApp||"",localStorage.setItem("selectedApp",this.context.selectedApp||"")}}),p.addTransition(g,{condition:()=>!e("APP_NAME")&&!this.context.selectedApp,action:()=>{const t=this.context.apps[0].id;this.context.selectedApp!==t&&(this.service.codicent=t,localStorage.setItem("selectedApp",t),this.updateContext({selectedApp:t}))}}),p.addTransition(g,{condition:()=>this.context.apps.some((t=>t.id===e("APP_NAME"))),action:()=>{const t=e("APP_NAME");this.context.selectedApp!==t&&(this.service.codicent=t,this.updateContext({selectedApp:t}))}}),p.addTransition(l,{condition:()=>!this.context.apps.some((t=>t.id===this.context.selectedApp||t.id===e("APP_NAME"))),action:()=>console.log("checking access -> no access",this.context.apps,this.context.selectedApp,e("APP_NAME"))}),g.addTransition(u,{condition:()=>!!localStorage.getItem("selectedApp")&&localStorage.getItem("selectedApp")!==this.context.selectedApp,action:()=>{this.service.codicent=localStorage.getItem("selectedApp")||"",this.updateContext({selectedApp:localStorage.getItem("selectedApp")||void 0})}}),r.addTransition(a,{condition:()=>!0===this.context.isRegistered}),r.addTransition(x,{condition:()=>!!this.context.error}),d.addTransition(c,{condition:()=>void 0===this.context.hasValidPurchase,action:()=>{window.history.replaceState({},document.title,window.location.pathname),this.checkPurchase()}}),[n,h,c,m,r].forEach((t=>{t.addTransition(x,{condition:()=>this.context.error?.includes("network")||this.context.error?.includes("connectivity")||!1}),t.addTransition(x,{condition:()=>!!this.context.error})})),[o,a,g,l].forEach((t=>{t.addTransition(A,{condition:()=>!1===this.context.isAuthenticated})})),a.addTransition(u,{condition:()=>!this.context.user&&!!this.context.nickname}),u.addTransition(c,{condition:()=>!!this.context.name&&e("SUBSCRIPTION_NEEDED")}),u.addTransition(h,{condition:()=>!!this.context.name&&!e("SUBSCRIPTION_NEEDED")}),x.addTransition(c,{condition:()=>!this.context.error&&"ErrorCheckingPurchase"!==this.context.errorType}),x.addTransition(h,{condition:()=>!this.context.error&&"ErrorGettingApps"!==this.context.errorType}),x.addTransition(p,{condition:()=>!this.context.error&&"ErrorCheckingAccess"!==this.context.errorType}),x.addTransition(u,{condition:()=>!this.context.error&&"ErrorLoadingUser"!==this.context.errorType}),x.addTransition(T,{condition:()=>!this.context.error&&"ErrorCreatingApp"!==this.context.errorType}),x.addTransition(m,{condition:()=>!this.context.error&&"CodicentLoginFailed"!==this.context.errorType}),A.addTransition(i,{condition:()=>!this.context.isAuthenticated&&!this.context.accessToken}),[i,g,s,x,A,n,o,a].forEach((t=>{t.addTransition(S,{condition:()=>!0===this.context.isAnonymous&&!!e("ANONYMOUS_TOKEN")})}));const v={initial:i,authenticating:n,notAuthenticated:s,authenticated:o,checkingCodicentAccess:m,registering:r,registered:a,checkingPurchase:c,needsPurchase:d,gettingApps:h,creatingApp:T,checkingAccess:p,noAccess:l,error:x,loadingUser:u,loggingOut:A,hasAccess:g,anonymous:S};return this.states.push(...Object.values(v)),v}get error(){return this.context.error}checkPurchase(){this.service.checkSubscriptionStatus().then((t=>this.updateContext({hasValidPurchase:"active"===t}))).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorCheckingPurchase"})))}getApps(){this.service.getApps().then((t=>{if(null===t)throw new Error("Failed to fetch apps.");e("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e("APP_PREFIX"))))),this.updateContext({apps:t,hasApps:!0,appsLoaded:!0}),this.context.selectedApp&&!t.some((t=>t.id===this.context.selectedApp))&&this.updateContext({selectedApp:void 0})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorGettingApps"})))}setUser(t){this.context.user=t}getContext(){return{...this.context}}updateContext(t){this.context={...this.context,...t}}getCurrentStateName(){const t=Object.entries(this.allStates).find((([t,e])=>e===this.current));return t?t[0]:""}logout(){localStorage.clear(),sessionStorage.clear(),this.resetContext()}setSelectedApp(t){localStorage.setItem("selectedApp",t),this.update()}isBusy(){return this.current===this.allStates.gettingApps||this.current===this.allStates.checkingPurchase||this.current===this.allStates.checkingAccess||this.current===this.allStates.checkingCodicentAccess||this.current===this.allStates.registering||this.current===this.allStates.loadingUser||this.current===this.allStates.creatingApp||this.current===this.allStates.loggingOut}}const n=(t,e)=>new i(t,e);export{i as AppStateMachine,n as createAppStateMachine,i as default};
1
+ import{d as t}from"../_virtual/index.js";import{getConfigValue as e}from"../config/index.js";class i extends t.StateMachine{constructor(t,e){super(),this.context={isAuthenticated:void 0,hasAccess:!1,error:null,errorType:void 0,apps:[],hasApps:!1,appsLoaded:!1},this.currentStateName="",this.resetContext(),this.service=t,this.onStateChange=e,this.allStates=this.initializeStateMachine()}resetContext(){this.context={isAuthenticated:!1,isRegistered:void 0,hasValidPurchase:void 0,hasAccess:!1,selectedApp:void 0,error:null,errorType:void 0,accessToken:void 0,nickname:void 0,apps:[],hasApps:!1,appsLoaded:!1},e("APP_NAME")?localStorage.removeItem("selectedApp"):this.context.selectedApp=localStorage.getItem("selectedApp")||void 0,e("APP_PREFIX")&&this.context.selectedApp&&!this.context.selectedApp.startsWith(e("APP_PREFIX"))?this.context.selectedApp=void 0:this.context.selectedApp}update(){super.update()}handlePurchase(){window.location.href="./#/purchase"}initializeStateMachine(){const i=new t.State,n=new t.State({entering:()=>{this.context.selectedApp&&!this.service.codicent&&(this.service.codicent=this.context.selectedApp)}}),s=new t.State,o=new t.State,r=new t.State({entering:()=>{this.service.findUsername().then((t=>{t?this.service.nicknameExists(t).then((e=>{e?this.updateContext({error:"Användarnamnet finns redan.",errorType:"UsernameExists"}):this.service.registerUser(t,this.context.user.email,this.context.user.sub,this.context.accessToken).then((()=>{this.service.setToken(this.context.accessToken),this.updateContext({nickname:t,isRegistered:!0})})).catch((t=>{console.warn("Failed to register account",t),this.updateContext({error:"Ett fel uppstod vid registrering. Försök igen senare.",errorType:"ErrorRegistering"})}))})).catch((t=>{console.warn("Failed to check username",t),this.updateContext({error:"Ett fel uppstod vid kontroll av användarnamn.",errorType:"ErrorCheckingUsername"})})):this.updateContext({error:"Användarnamn kunde inte hittas.",errorType:"NoUsernameFound"})})).catch((t=>{console.warn("Failed to find username",t),this.updateContext({error:"Ett fel uppstod vid sökning av användarnamn.",errorType:"ErrorFindingUsername"})}))}}),a=new t.State,c=new t.State({entering:()=>{this.checkPurchase()}}),d=new t.State({entering:()=>{this.handlePurchase()}}),h=new t.State({entering:()=>{this.getApps()}}),p=new t.State,l=new t.State,g=new t.State({}),x=new t.State,u=new t.State({entering:()=>{this.context.nickname&&(localStorage.setItem("nickname",this.context.nickname),this.service.getUserInfo(this.context.nickname).then((t=>{const e=t?.name||t?.nickname||"";this.updateContext({name:e})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorLoadingUser"}))))}}),A=new t.State({entering:()=>{localStorage.removeItem("selectedApp"),localStorage.removeItem("nickname"),localStorage.removeItem("codicent"),sessionStorage.clear(),this.updateContext({isAuthenticated:!1,isRegistered:void 0,apps:[],hasApps:!1,selectedApp:void 0,accessToken:void 0,user:void 0}),setTimeout((()=>{this.current=this.allStates.initial}),1e3)}}),T=new t.State({entering:()=>{this.service.createApp().then((t=>{t?(this.service.codicent=t,this.updateContext({selectedApp:t,apps:[...this.context.apps||[],{id:t,title:t,logo:""}]})):this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})})).catch((t=>{console.warn("Error creating app",t),this.updateContext({error:"Misslyckades att skapa din app. Försök igen senare.",errorType:"ErrorCreatingApp"})}))}}),m=new t.State({entering:()=>{this.service.loginUser(this.context.user.sub,this.context.accessToken).then((t=>{null===t?this.updateContext({isRegistered:!1}):""===t?this.updateContext({isRegistered:!1,error:"Kunde inte logga in hos Codicent.",errorType:"CodicentLoginFailed"}):(this.service.setToken(this.context.accessToken),this.service.getNickname().then((t=>{t?this.updateContext({isRegistered:!0,nickname:t}):this.updateContext({error:"Kunde inte hitta användarnamn.",errorType:"ErrorFindingUsername"})})).catch((()=>{this.updateContext({error:"Fel vid hämtning av användarnamn.",errorType:"ErrorFindingUsername"})})))})).catch((()=>{this.updateContext({isRegistered:!1,error:"Fel vid inloggning hos Codicent.",errorType:"CodicentLoginError"})}))}}),S=new t.State({entering:()=>{this.service.setToken(e("ANONYMOUS_TOKEN")),this.service.codicent=e("ANONYMOUS_CODICENT")||e("APP_NAME")||""}});i.addTransition(n,{condition:()=>!0}),n.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),n.addTransition(x,{condition:()=>Boolean(this.context.error)}),n.addTransition(s,{condition:()=>!1===this.context.isAuthenticated}),s.addTransition(o,{condition:()=>!0===this.context.isAuthenticated}),s.addTransition(x,{condition:()=>!!this.context.error}),o.addTransition(m,{}),m.addTransition(r,{condition:()=>!1===this.context.isRegistered}),m.addTransition(a,{condition:()=>!0===this.context.isRegistered}),m.addTransition(x,{condition:()=>!!this.context.error}),a.addTransition(u,{condition:()=>!!this.context.nickname}),a.addTransition(x,{condition:()=>!this.context.nickname,action:()=>this.updateContext({error:"Missing nickname after registration",errorType:"ErrorLoadingUser"})}),c.addTransition(d,{condition:()=>!1===this.context.hasValidPurchase}),c.addTransition(h,{condition:()=>!0===this.context.hasValidPurchase}),h.addTransition(x,{condition:()=>!!this.context.error,action:()=>console.log("getting apps -> error")}),h.addTransition(p,{condition:()=>!!e("APP_NAME")&&this.context.hasApps}),h.addTransition(T,{condition:()=>!e("APP_NAME")&&this.context.appsLoaded&&0===this.context.apps.length,action:()=>this.updateContext({selectedApp:void 0})}),h.addTransition(p,{condition:()=>!e("APP_NAME")&&this.context.hasApps&&this.context.apps.length>0}),T.addTransition(p,{condition:()=>!!this.context.selectedApp}),T.addTransition(x,{condition:()=>!!this.context.error}),p.addTransition(g,{condition:()=>!e("APP_NAME")&&this.context.apps.some((t=>t.id===this.context.selectedApp)),action:()=>{this.service.codicent=this.context.selectedApp||"",localStorage.setItem("selectedApp",this.context.selectedApp||"")}}),p.addTransition(g,{condition:()=>!e("APP_NAME")&&!this.context.selectedApp,action:()=>{const t=this.context.apps[0].id;this.context.selectedApp!==t&&(this.service.codicent=t,localStorage.setItem("selectedApp",t),this.updateContext({selectedApp:t}))}}),p.addTransition(g,{condition:()=>this.context.apps.some((t=>t.id===e("APP_NAME"))),action:()=>{const t=e("APP_NAME");this.context.selectedApp!==t&&(this.service.codicent=t,this.updateContext({selectedApp:t}))}}),p.addTransition(l,{condition:()=>!this.context.apps.some((t=>t.id===this.context.selectedApp||t.id===e("APP_NAME"))),action:()=>console.log("checking access -> no access",this.context.apps,this.context.selectedApp,e("APP_NAME"))}),g.addTransition(u,{condition:()=>!!localStorage.getItem("selectedApp")&&localStorage.getItem("selectedApp")!==this.context.selectedApp,action:()=>{this.service.codicent=localStorage.getItem("selectedApp")||"",this.updateContext({selectedApp:localStorage.getItem("selectedApp")||void 0})}}),r.addTransition(a,{condition:()=>!0===this.context.isRegistered}),r.addTransition(x,{condition:()=>!!this.context.error}),d.addTransition(c,{condition:()=>void 0===this.context.hasValidPurchase,action:()=>{window.history.replaceState({},document.title,window.location.pathname),this.checkPurchase()}}),[n,h,c,m,r].forEach((t=>{t.addTransition(x,{condition:()=>this.context.error?.includes("network")||this.context.error?.includes("connectivity")||!1}),t.addTransition(x,{condition:()=>!!this.context.error})})),[o,a,g,l].forEach((t=>{t.addTransition(A,{condition:()=>!1===this.context.isAuthenticated})})),a.addTransition(u,{condition:()=>!this.context.user&&!!this.context.nickname}),u.addTransition(c,{condition:()=>!!this.context.name&&e("SUBSCRIPTION_NEEDED")}),u.addTransition(h,{condition:()=>!!this.context.name&&!e("SUBSCRIPTION_NEEDED")}),x.addTransition(c,{condition:()=>!this.context.error&&"ErrorCheckingPurchase"!==this.context.errorType}),x.addTransition(h,{condition:()=>!this.context.error&&"ErrorGettingApps"!==this.context.errorType}),x.addTransition(p,{condition:()=>!this.context.error&&"ErrorCheckingAccess"!==this.context.errorType}),x.addTransition(u,{condition:()=>!this.context.error&&"ErrorLoadingUser"!==this.context.errorType}),x.addTransition(T,{condition:()=>!this.context.error&&"ErrorCreatingApp"!==this.context.errorType}),x.addTransition(m,{condition:()=>!this.context.error&&"CodicentLoginFailed"!==this.context.errorType}),A.addTransition(i,{condition:()=>!this.context.isAuthenticated&&!this.context.accessToken}),[i,g,s,x,A,n,o,a].forEach((t=>{t.addTransition(S,{condition:()=>!0===this.context.isAnonymous&&!!e("ANONYMOUS_TOKEN")})}));const v={initial:i,authenticating:n,notAuthenticated:s,authenticated:o,checkingCodicentAccess:m,registering:r,registered:a,checkingPurchase:c,needsPurchase:d,gettingApps:h,creatingApp:T,checkingAccess:p,noAccess:l,error:x,loadingUser:u,loggingOut:A,hasAccess:g,anonymous:S};return this.states.push(...Object.values(v)),v}get error(){return this.context.error}checkPurchase(){this.service.checkSubscriptionStatus().then((t=>this.updateContext({hasValidPurchase:"active"===t}))).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorCheckingPurchase"})))}getApps(){this.service.getApps().then((t=>{if(null===t)throw new Error("Failed to fetch apps.");e("APP_PREFIX")&&(t=t.filter((t=>t.id.startsWith(e("APP_PREFIX"))))),this.updateContext({apps:t,hasApps:!0,appsLoaded:!0}),this.context.selectedApp&&!t.some((t=>t.id===this.context.selectedApp))&&this.updateContext({selectedApp:void 0})})).catch((t=>this.updateContext({error:t.toString(),errorType:"ErrorGettingApps"})))}setUser(t){this.context.user=t}getContext(){return{...this.context}}updateContext(t){this.context={...this.context,...t}}getCurrentStateName(){const t=Object.entries(this.allStates).find((([t,e])=>e===this.current));return t?t[0]:""}logout(){localStorage.clear(),sessionStorage.clear(),this.resetContext()}setSelectedApp(t){localStorage.setItem("selectedApp",t),this.update()}isBusy(){return this.current===this.allStates.gettingApps||this.current===this.allStates.checkingPurchase||this.current===this.allStates.checkingAccess||this.current===this.allStates.checkingCodicentAccess||this.current===this.allStates.registering||this.current===this.allStates.loadingUser||this.current===this.allStates.creatingApp||this.current===this.allStates.loggingOut}}const n=(t,e)=>new i(t,e);export{i as AppStateMachine,n as createAppStateMachine,i as default};
package/dist/index.d.ts CHANGED
@@ -790,24 +790,15 @@ interface AppConfigOptions {
790
790
  FORM_BACKGROUND_IMAGE_URL: undefined | string;
791
791
  AUTO_TRANSLATE: boolean;
792
792
  APP_LOGBOOK_TITLE: undefined | string;
793
+ LOGIN_WELCOME_TEXT: string | undefined;
794
+ LOGIN_HIDE_WELCOME: boolean;
795
+ LOGIN_LOGO_URL: string | undefined;
793
796
  }
794
797
  declare function getConfigValue<K extends keyof AppConfigOptions>(key: K): AppConfigOptions[K];
795
798
  /**
796
799
  * Initialize the Codicent App SDK with configuration options
797
800
  */
798
801
  declare function initCodicentApp(options?: Partial<AppConfigOptions>): void;
799
- declare global {
800
- interface Window {
801
- updateCodicentConfig: (config: Record<string, any>) => void;
802
- }
803
- }
804
- /**
805
- * Updates the existing configuration object with new values from the provided `newConfig` object.
806
- * Only properties that already exist on the original `config` object will be updated.
807
- *
808
- * @param newConfig - An object containing configuration properties to update.
809
- */
810
- declare const updateConfig: (newConfig: Record<string, any>) => void;
811
802
 
812
803
  declare const AppFrame: ({ src, showFooter, title, }: {
813
804
  src: string;
@@ -851,4 +842,4 @@ declare const Sales: React__default.FC<{
851
842
  state: CodicentAppState;
852
843
  }>;
853
844
 
854
- export { AiInput, AppConfig, AppConfigOptions, AppFrame, AppInfo, AppStateDefinition, AppStateMachine, AudioIcon, AudioRecorder, AudioRecorderState, Button, ChatInput, ChatMessage, CodicentAppState, CodicentService, CodicentServiceOptions, CombinedPlaceholderDialog, Content, CrmPage, FilePlaceholder, FileThumbnail, Footer, FormAccept, FormInvite, Header, HtmlView, ImageViewer as ImageView, Input, Label, Login, Logout, Markdown, Message$1 as Message, Content$1 as MessageContent, MessageInput, MessageItem, Page, Profile, Prompt, RealtimeVoice, Sales, Search, SearchBox, Snap, SnapFooter, Spinner, StateContext, TemplateVariable, Text, TextHeader, Textarea, Title, TypingIndicator, UploadFile, UploadFileProps, UploadFileRef, UrlProcessor, UseAuthState, UserInfo, VoiceIcon, WavRecorder, WavStreamPlayer, createAppStateMachine, generateBrandVariants, getConfigValue, getGpsLocation, getTimeString, initCodicentApp, isMobileDevice, log, updateConfig, useAppStyles, useAudioRecorder, useAuthState, useChat, useCodicentApp, useCodicentState, useLocalization, useRealtimeVoiceAI, useStateWithLocalStorage, useTemplateVariables, useToaster, useTools, withWakeLock };
845
+ export { AiInput, AppConfig, AppConfigOptions, AppFrame, AppInfo, AppStateDefinition, AppStateMachine, AudioIcon, AudioRecorder, AudioRecorderState, Button, ChatInput, ChatMessage, CodicentAppState, CodicentService, CodicentServiceOptions, CombinedPlaceholderDialog, Content, CrmPage, FilePlaceholder, FileThumbnail, Footer, FormAccept, FormInvite, Header, HtmlView, ImageViewer as ImageView, Input, Label, Login, Logout, Markdown, Message$1 as Message, Content$1 as MessageContent, MessageInput, MessageItem, Page, Profile, Prompt, RealtimeVoice, Sales, Search, SearchBox, Snap, SnapFooter, Spinner, StateContext, TemplateVariable, Text, TextHeader, Textarea, Title, TypingIndicator, UploadFile, UploadFileProps, UploadFileRef, UrlProcessor, UseAuthState, UserInfo, VoiceIcon, WavRecorder, WavStreamPlayer, createAppStateMachine, generateBrandVariants, getConfigValue, getGpsLocation, getTimeString, initCodicentApp, isMobileDevice, log, useAppStyles, useAudioRecorder, useAuthState, useChat, useCodicentApp, useCodicentState, useLocalization, useRealtimeVoiceAI, useStateWithLocalStorage, useTemplateVariables, useToaster, useTools, withWakeLock };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codicent-app-sdk",
3
- "version": "0.3.60",
3
+ "version": "0.3.63",
4
4
  "description": "SDK for building AI-powered applications with Codicent",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",