codicent-app-sdk 0.3.34 → 0.3.36

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthState.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAUrC,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IAInB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,eAAe,EAAE,eAAe,CAAC;IACjC,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChF;AAED,QAAA,MAAM,YAAY,UAAW,qBAAqB,KAAG,YAsOpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"useAuthState.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAUrC,MAAM,WAAW,YAAY;IAC3B,eAAe,EAAE,OAAO,CAAC;IACzB,YAAY,EAAE,OAAO,GAAG,SAAS,CAAC;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IAInB,IAAI,EAAE,GAAG,CAAC;IACV,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACpD,eAAe,EAAE,eAAe,CAAC;IACjC,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChF;AAED,QAAA,MAAM,YAAY,UAAW,qBAAqB,KAAG,YAuOpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../services/codicent.js");require("../components/Markdown.js"),require("../components/Textarea.js"),require("../components/Button.js"),require("react/jsx-runtime"),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");var o=require("../config/index.js");require("../stores/chatStore.js"),require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.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"),require("./useLocalization.js"),require("./useAppStyles.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("../pages/AppFrame.js"),require("../pages/Snap.js"),require("../pages/Search.js"),require("../pages/Login.js"),require("../pages/CrmPage.js"),require("../pages/ImageView.js"),require("../pages/FormInvite.js"),require("../pages/FormAccept.js"),require("../pages/Sales.js");exports.default=s=>{const{isAuthenticated:t,getAccessTokenSilently:n,user:i,isLoading:u,logout:a,getAccessTokenWithPopup:c,loginWithRedirect:l}=s,[g,p]=e.useState(null),[q,j]=e.useState(void 0),[E,C]=e.useState(null),[m,P]=e.useState(""),_=e.useMemo((()=>new r.CodicentService({API_BASE_URL:o.getConfigValue("API_BASE_URL"),APP_LOG_CODICENT:o.getConfigValue("APP_LOG_CODICENT"),APP_LOG_TOKEN:o.getConfigValue("APP_LOG_TOKEN"),APP_NAME:o.getConfigValue("APP_NAME"),APP_PREFIX:o.getConfigValue("APP_PREFIX"),APP_TEMPLATE:o.getConfigValue("APP_TEMPLATE"),BUTTON_TAG:o.getConfigValue("BUTTON_TAG"),STRIPE_PUBLIC_KEY:o.getConfigValue("STRIPE_PUBLIC_KEY"),SUBSCRIPTION_NEEDED:o.getConfigValue("SUBSCRIPTION_NEEDED"),USER_PREFIX:o.getConfigValue("USER_PREFIX")})),[]);e.useEffect((()=>{u||(async()=>{try{const e=await n({});console.debug("CODICENT: ACCESS TOKEN",e),p(e)}catch(e){console.debug("CODICENT: Failed to get access token",e);const r=e;if(r&&"object"==typeof r&&"error"in r&&"login_required"===r.error)console.warn("CODICENT: Login required"),d();else if(r&&"object"==typeof r&&"error"in r&&"consent_required"===r.error)try{const e=await c();if(!e)return void C("Failed to get access token: no token from auth0 with popup");console.log("CODICENT: GOT ACCESS TOKEN"),p(e)}catch(e){console.warn("CODICENT: Failed to get access token with popup",e),d()}else C("Failed to get access token: "+(r.message?.toString()||r.toString())),console.log("CODICENT: ACCESS TOKEN ERROR",r)}})().then((()=>{}))}),[t,c,n,l,u]),e.useEffect((()=>{if(i&&i.sub&&g&&void 0===q){let e=!0;return _.loginUser(i.sub,g).then((r=>{e&&(null===r?j(!1):""===r?C("Kontrollera internetanslutningen och försök igen."):(_.setToken(g),_.getNickname().then(P),j(!0)))})).catch((()=>{e&&(C("Ett fel uppstod. Försök igen senare."),j(!1))})),()=>{e=!1}}}),[i,g,q,_]);const d=()=>{_.logout(),p(null),C(null),j(void 0),P(""),a({logoutParams:{returnTo:o.getConfigValue("AUTH_REDIRECT_URL")}})};return{isAuthenticated:t,isRegistered:q,accessToken:g,authError:E,isLoading:u,user:i,nickname:m,logout:d,registerUser:async e=>{const r=await _.registerUser(e,i.email,i.sub,g);return r&&(_.setToken(g),j(!0)),r},codicentService:_,loginWithRedirect:l}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("../services/codicent.js");require("../components/Markdown.js"),require("../components/Textarea.js"),require("../components/Button.js"),require("react/jsx-runtime"),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");var o=require("../config/index.js");require("../stores/chatStore.js"),require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.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"),require("./useLocalization.js"),require("./useAppStyles.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("../pages/AppFrame.js"),require("../pages/Snap.js"),require("../pages/Search.js"),require("../pages/Login.js"),require("../pages/CrmPage.js"),require("../pages/ImageView.js"),require("../pages/FormInvite.js"),require("../pages/FormAccept.js"),require("../pages/Sales.js");exports.default=s=>{const{isAuthenticated:t,getAccessTokenSilently:n,user:i,isLoading:u,logout:a,getAccessTokenWithPopup:c,loginWithRedirect:l}=s,[g,p]=e.useState(null),[q,E]=e.useState(void 0),[j,C]=e.useState(null),[m,_]=e.useState(""),T=e.useMemo((()=>new r.CodicentService({API_BASE_URL:o.getConfigValue("API_BASE_URL"),APP_LOG_CODICENT:o.getConfigValue("APP_LOG_CODICENT"),APP_LOG_TOKEN:o.getConfigValue("APP_LOG_TOKEN"),APP_NAME:o.getConfigValue("APP_NAME"),APP_PREFIX:o.getConfigValue("APP_PREFIX"),APP_TEMPLATE:o.getConfigValue("APP_TEMPLATE"),BUTTON_TAG:o.getConfigValue("BUTTON_TAG"),STRIPE_PUBLIC_KEY:o.getConfigValue("STRIPE_PUBLIC_KEY"),SUBSCRIPTION_NEEDED:o.getConfigValue("SUBSCRIPTION_NEEDED"),USER_PREFIX:o.getConfigValue("USER_PREFIX"),ANONYMOUS_TOKEN:o.getConfigValue("ANONYMOUS_TOKEN")})),[]);e.useEffect((()=>{u||(async()=>{try{const e=await n({});console.debug("CODICENT: ACCESS TOKEN",e),p(e)}catch(e){console.debug("CODICENT: Failed to get access token",e);const r=e;if(r&&"object"==typeof r&&"error"in r&&"login_required"===r.error)console.warn("CODICENT: Login required"),P();else if(r&&"object"==typeof r&&"error"in r&&"consent_required"===r.error)try{const e=await c();if(!e)return void C("Failed to get access token: no token from auth0 with popup");console.log("CODICENT: GOT ACCESS TOKEN"),p(e)}catch(e){console.warn("CODICENT: Failed to get access token with popup",e),P()}else C("Failed to get access token: "+(r.message?.toString()||r.toString())),console.log("CODICENT: ACCESS TOKEN ERROR",r)}})().then((()=>{}))}),[t,c,n,l,u]),e.useEffect((()=>{if(i&&i.sub&&g&&void 0===q){let e=!0;return T.loginUser(i.sub,g).then((r=>{e&&(null===r?E(!1):""===r?C("Kontrollera internetanslutningen och försök igen."):(T.setToken(g),T.getNickname().then(_),E(!0)))})).catch((()=>{e&&(C("Ett fel uppstod. Försök igen senare."),E(!1))})),()=>{e=!1}}}),[i,g,q,T]);const P=()=>{T.logout(),p(null),C(null),E(void 0),_(""),a({logoutParams:{returnTo:o.getConfigValue("AUTH_REDIRECT_URL")}})};return{isAuthenticated:t,isRegistered:q,accessToken:g,authError:j,isLoading:u,user:i,nickname:m,logout:P,registerUser:async e=>{const r=await T.registerUser(e,i.email,i.sub,g);return r&&(T.setToken(g),E(!0)),r},codicentService:T,loginWithRedirect:l}};
2
2
  //# sourceMappingURL=useAuthState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthState.js","sources":["../../../../src/hooks/useAuthState.ts"],"sourcesContent":[null],"names":["isAuthenticated","getAccessTokenSilently","user","isLoading","logout","getAccessTokenWithPopup","loginWithRedirect","auth0","accessToken","setAccessToken","useState","isRegistered","setIsRegistered","undefined","authError","setAuthError","nickname","setNickname","codicentService","useMemo","CodicentService","API_BASE_URL","getConfigValue","APP_LOG_CODICENT","APP_LOG_TOKEN","APP_NAME","APP_PREFIX","APP_TEMPLATE"],"mappings":"qwDAcE,MAAAA,gBAAAA,EAAwBC,uBAAAA,EAAUC,KAAAA,EAAAC,UAAAA,EAAAC,OAAAA,EAAAC,wBAAAA,EAAAC,kBAAAA,GAAAC,GAClCC,EAAsBC,GAAKC,EAAAA,SAAA,OAC3BC,EAAoBC,GAAKF,EAAAA,cAAAG,IAChBC,EAASC,GAACL,EAAAA,SAAA,OAKXM,EAASC,GAAAP,EAAAA,SAAA,IACXQ,EAAaC,EAAAA,SAAA,IAAA,IAAAC,kBAAA,CACPC,aAAGC,iCACAC,mBAAkBD,eAAA,oBACjCE,cAAmBF,EAA+BA,eAAA,iBACnDG,SAAAH,EAAAA,eAAA,YAEDI,WAAkBJ,EAAAA,eAAA,cAwOlBK,eAA4BL,eAAA"}
1
+ {"version":3,"file":"useAuthState.js","sources":["../../../../src/hooks/useAuthState.ts"],"sourcesContent":[null],"names":["isAuthenticated","getAccessTokenSilently","user","isLoading","logout","getAccessTokenWithPopup","loginWithRedirect","auth0","accessToken","setAccessToken","useState","isRegistered","setIsRegistered","undefined","authError","setAuthError","nickname","setNickname","codicentService","useMemo","CodicentService","API_BASE_URL","getConfigValue","APP_LOG_CODICENT","APP_LOG_TOKEN","APP_NAME","APP_PREFIX","APP_TEMPLATE"],"mappings":"qwDAcE,MAAAA,gBAAAA,EAAwBC,uBAAAA,EAAUC,KAAAA,EAAAC,UAAAA,EAAAC,OAAAA,EAAAC,wBAAAA,EAAAC,kBAAAA,GAAAC,GAClCC,EAAsBC,GAAKC,EAAAA,SAAA,OAC3BC,EAAoBC,GAAKF,EAAAA,cAAAG,IAChBC,EAASC,GAACL,EAAAA,SAAA,OAKXM,EAASC,GAAAP,EAAAA,SAAA,IACXQ,EAAaC,EAAAA,SAAA,IAAA,IAAAC,kBAAA,CACPC,aAAGC,iCACAC,mBAAkBD,eAAA,oBACjCE,cAAmBF,EAA+BA,eAAA,iBACnDG,SAAAH,EAAAA,eAAA,YAEDI,WAAkBJ,EAAAA,eAAA,cAyOlBK,eAA4BL,eAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"CrmPage.d.ts","sourceRoot":"","sources":["../../../src/pages/CrmPage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAA+B,MAAM,UAAU,CAAC;AAuDzE,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CA8QzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"CrmPage.d.ts","sourceRoot":"","sources":["../../../src/pages/CrmPage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAA+B,MAAM,UAAU,CAAC;AAuDzE,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAoRzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("../services/codicent.js");require("../components/Markdown.js"),require("../components/Textarea.js"),require("../components/Button.js"),require("../components/Spinner.js");var r=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");var o=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var a=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");var i=require("../components/MessageInput.js"),s=require("../components/UploadFile.js");require("../components/SnapFooter.js"),require("../components/Profile.js"),require("../components/MessageItem.js"),require("../components/Content.js");var l=require("../components/AiInput.js");require("../components/SearchBox.js"),require("../components/HtmlView.js"),require("../components/Footer.js");var u=require("../components/Page.js");require("./AppFrame.js"),require("./Snap.js"),require("./Search.js"),require("./Login.js"),require("./ImageView.js"),require("./FormInvite.js"),require("./FormAccept.js"),require("./Sales.js"),require("../stores/chatStore.js");var c=require("../hooks/useLocalization.js");require("../hooks/useAppStyles.js");var d=require("../hooks/useToaster.js"),p=require("react-router-dom"),m=require("../node_modules/lodash/lodash.js"),g=require("../node_modules/@griffel/react/makeStyles.esm.js"),j=require("../node_modules/@griffel/core/index.esm.js"),f=require("../node_modules/@fluentui/tokens/lib/tokens.js");const h=g.makeStyles({main:{flexGrow:1,...j.shorthands.padding("10px"),overflowY:"auto"},container:{maxWidth:"640px",margin:"0 auto",backgroundPosition:"calc(50% + 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"100%"},root:{height:"100%"},item:{height:"auto",width:"auto",flexShrink:1,marginBottom:"1rem"},chat:{flexGrow:1,boxSizing:"border-box",overflow:"hidden",border:"none"},attachmentBar:{display:"none"},iconButton:{width:"24px",height:"24px"},imageCard:{alignContent:"center",borderRadius:f.tokens.borderRadiusLarge,height:"240px",textAlign:"left",position:"relative"}}),v=({state:g})=>{const j=h(),{t:f}=c.default(),[v,q]=t.useState(!1),x=t.useRef(null),k=t.useRef(null),S=t.useRef(null),[b]=t.useState(null),[C,$]=t.useState([]),{service:w}=g,[y,T]=p.useSearchParams(),[_,E]=t.useState(""),[M,U]=t.useState(void 0),[I,P]=t.useState(void 0),[F,V]=t.useState(void 0),[A,K]=t.useState(void 0),R=d.default(),O=[f("Kundinteraktion"),f("Försäljningsaktivitet"),f("Offertskapande"),f("Att-göra-uppgift")],L=[f("Kund 1"),f("Kund 2"),f("Kund 3")],B=[f("Kontakt 1"),f("Kontakt 2"),f("Kontakt 3")],N=e=>`Vilken typ av CRM-aktivitet är det? Välj från ${O[0]}, ${O[1]}, ${O[2]} eller ${O[3]}. Svara bara med en av dessa, ingen annan text.\nTEXT:\n\n${e}`,D=e=>`Vilken kund är det? Välj från ${L[0]}, ${L[1]} eller ${L[2]}. Svara med en av dessa om de matchar, annars extrahera nytt kundnamn från texten, ingen annan text.\nTEXT:\n\n${e}`,G=e=>`Vilken kontakt är det? Svara med kontaktnamn från texten om det går, ingen annan text.\nTEXT:\n\n${e}`,H=t.useCallback((e=>{for(const t of e)w.getFileInfo(t).then((e=>{$((t=>[...t,e]))}))}),[w,$]),z=t.useCallback((e=>{const t=new FormData;t.append("file",e),w.uploadFile(e.name,t).then((e=>{H([e])})).catch((()=>{R.notify(f("Error"),f("Error uploading pasted image"),"")}))}),[w,H,R,f]),X=e=>{q(e)};t.useEffect((()=>{const e=y.get("text"),t=y.get("url");e&&(E(e),y.delete("text")),t&&(y.delete("url"),E(((e||"")+" "+t).trim())),T(y,{replace:!0})}),[y,T,E,w,H]);const Y=t.useCallback((async e=>{if(!e)return;const t=await w.chat(N(e));if(t){const e=new o.default(t.content);console.log("typeMsg",e.content),U(e.content)}const n=await w.chat(D(e));if(n){const e=new o.default(n.content);console.log("customerMsg",e.content),P(e.content)}const r=await w.chat(G(e));if(r){const e=new o.default(r.content);console.log("contactMsg",e.content),V(e.content)}}),[w]),J=t.useMemo((()=>m.lodashExports.debounce(Y,1e3)),[Y]);return t.useEffect((()=>()=>{J.cancel()}),[J]),e.jsx(u.Page,{hideHeader:!0,children:e.jsxs("div",{className:j.container,style:{backgroundImage:`url(${a.getConfigValue("COMPOSE_BACKGROUND_IMAGE_URL")})`},children:[e.jsx(r.default,{title:a.getConfigValue("APP_SAVE_TITLE")?f(a.getConfigValue("APP_SAVE_TITLE")):f("Spara")}),e.jsx(i.default,{defaultText:_,onSend:e=>{if(M===O[3])e+=`\nTYPE: ${M||""}\nCUSTOMER: ${I||""}\nCONTACT: ${F||""}`,e=`${e+=`\nSALESPERSON: ${g.context.name||g.context.user?.email||g.context.nickname||"-"}`}${b?" "+b:""}${M===O[3]?" #todo ":""}${C.map((e=>`#file:${e.id}`)).join(" ")}`;else{const t=JSON.stringify({type:M,customer:I,contact:F,message:e.replace("#log ",""),salesperson:g.context.name||g.context.user?.email||g.context.nickname||"-"});e=`${e="#crm #data\n"+t}${b?" "+b:""}${C.length>0?"\n":""}${C.map((e=>`#file:${e.id}`)).join(" ")}`}w.sendMessage(e).then((()=>{R.notify(f("Meddelande"),f("Meddelandet är sparat."),"")}))},files:C,onFilesChange:$,isUploading:v,onUploadImage:()=>{k.current?.triggerUpload()},onUploadCamera:()=>{S.current?.triggerUpload()},getImageUrl:n.CodicentService.getImageUrl,hasLocation:!!b,disableSend:!0,rows:9,placeholder:f("Beskriv CRM-aktivitet här..."),onChange:e=>{K(e),J(e)},onImagePasted:z}),e.jsx(l.default,{title:f("Typ"),id:"crm-type",options:O,placeholder:f("Typ av aktivitet..."),value:M,onChangeValue:U,prompt:N(A||""),service:w}),e.jsx(l.default,{title:f("Kund"),id:"crm-customer",options:L,placeholder:f("Kund..."),value:I,onChangeValue:P,prompt:D(A||""),service:w}),e.jsx(l.default,{title:f("Kontakt"),id:"crm-contact",options:B,placeholder:f("Kontaktperson..."),value:F,onChangeValue:V,prompt:G(A||""),service:w}),e.jsx(s.default,{ref:x,onFileUploaded:H,onUploading:X,multiple:!0,codicentService:w}),e.jsx(s.default,{codicentService:w,ref:k,onFileUploaded:H,onUploading:X,multiple:!0,accept:"image/*"}),e.jsx(s.default,{codicentService:w,ref:S,onFileUploaded:H,onUploading:X,multiple:!0,accept:"image/*",capture:"environment"})]})})};exports.CrmPage=v,exports.default=v;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),o=require("../services/codicent.js");require("../components/Markdown.js"),require("../components/Textarea.js"),require("../components/Button.js"),require("../components/Spinner.js");var t=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 i=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");var n=require("../components/MessageInput.js"),s=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");var a=require("../components/Page.js");require("./AppFrame.js"),require("./Snap.js"),require("./Search.js"),require("./Login.js"),require("./ImageView.js"),require("./FormInvite.js"),require("./FormAccept.js"),require("./Sales.js"),require("../stores/chatStore.js");var l=require("../hooks/useLocalization.js");require("../hooks/useAppStyles.js");var u=require("../hooks/useToaster.js"),c=require("react-router-dom"),d=require("../node_modules/@griffel/react/makeStyles.esm.js"),p=require("../node_modules/@griffel/core/index.esm.js"),m=require("../node_modules/@fluentui/tokens/lib/tokens.js");const g=d.makeStyles({main:{flexGrow:1,...p.shorthands.padding("10px"),overflowY:"auto"},container:{maxWidth:"640px",margin:"0 auto",backgroundPosition:"calc(50% + 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"100%"},root:{height:"100%"},item:{height:"auto",width:"auto",flexShrink:1,marginBottom:"1rem"},chat:{flexGrow:1,boxSizing:"border-box",overflow:"hidden",border:"none"},attachmentBar:{display:"none"},iconButton:{width:"24px",height:"24px"},imageCard:{alignContent:"center",borderRadius:m.tokens.borderRadiusLarge,height:"240px",textAlign:"left",position:"relative"}}),j=({state:d})=>{const p=g(),{t:m}=l.default(),[j,q]=r.useState(!1),h=r.useRef(null),f=r.useRef(null),v=r.useRef(null),[x]=r.useState(null),[S,b]=r.useState([]),{service:C}=d,[k,_]=c.useSearchParams(),[w,I]=r.useState("");r.useState(void 0),r.useState(void 0),r.useState(void 0);const[U,y]=r.useState(void 0),F=u.default(),P=r.useCallback((e=>{for(const r of e)C.getFileInfo(r).then((e=>{b((r=>[...r,e]))}))}),[C,b]),M=r.useCallback((e=>{const r=new FormData;r.append("file",e),C.uploadFile(e.name,r).then((e=>{P([e])})).catch((()=>{F.notify(m("Error"),m("Error uploading pasted image"),"")}))}),[C,P,F,m]),A=e=>{q(e)};r.useEffect((()=>{const e=k.get("text"),r=k.get("url");e&&(I(e),k.delete("text")),r&&(k.delete("url"),I(((e||"")+" "+r).trim())),_(k,{replace:!0})}),[k,_,I,C,P]);return e.jsx(a.Page,{hideHeader:!0,children:e.jsxs("div",{className:p.container,style:{backgroundImage:`url(${i.getConfigValue("COMPOSE_BACKGROUND_IMAGE_URL")})`},children:[e.jsx(t.default,{title:i.getConfigValue("APP_SAVE_TITLE")?m(i.getConfigValue("APP_SAVE_TITLE")):m("Spara")}),e.jsx(n.default,{defaultText:w,onSend:e=>{e=`${e="#crm\n"+e.replace("#log ","")}${x?" "+x:""}${S.length>0?"\n":""}${S.map((e=>`#file:${e.id}`)).join(" ")}`,C.sendMessage(e).then((()=>{F.notify(m("Meddelande"),m("Meddelandet är sparat."),"")}))},files:S,onFilesChange:b,isUploading:j,onUploadImage:()=>{f.current?.triggerUpload()},onUploadCamera:()=>{v.current?.triggerUpload()},getImageUrl:o.CodicentService.getImageUrl,hasLocation:!!x,disableSend:!0,rows:9,placeholder:m("Beskriv CRM-aktivitet här..."),onChange:e=>{y(e)},onImagePasted:M}),e.jsx(s.default,{ref:h,onFileUploaded:P,onUploading:A,multiple:!0,codicentService:C}),e.jsx(s.default,{codicentService:C,ref:f,onFileUploaded:P,onUploading:A,multiple:!0,accept:"image/*"}),e.jsx(s.default,{codicentService:C,ref:v,onFileUploaded:P,onUploading:A,multiple:!0,accept:"image/*",capture:"environment"})]})})};exports.CrmPage=j,exports.default=j;
2
2
  //# sourceMappingURL=CrmPage.js.map
@@ -27,6 +27,7 @@ export interface CodicentServiceOptions {
27
27
  STRIPE_PUBLIC_KEY: string;
28
28
  SUBSCRIPTION_NEEDED: boolean;
29
29
  USER_PREFIX: string;
30
+ ANONYMOUS_TOKEN?: string;
30
31
  }
31
32
  export declare class CodicentService {
32
33
  codicent: string;
@@ -57,6 +58,7 @@ export declare class CodicentService {
57
58
  logout: () => void;
58
59
  isRegistered: () => boolean;
59
60
  getApps: () => Promise<AppInfo[] | null>;
61
+ addFollower: (nickname: string, followerNickname: string) => Promise<boolean>;
60
62
  cloneProject: (project: string, newProject: string) => Promise<boolean>;
61
63
  getNickname: () => Promise<string>;
62
64
  getChatInstructions: () => Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,QAAQ;IACvB,QAAQ,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AAqB,MAAM,sBAevE;IAEF,cAAc,aAvEiB,MAAM,wCAuEH;IAElC,mBAAmB,aAAoB,MAAM,WAAW,MAAM,EAAE,sBAe9D;IAEF,gBAAgB,aAAoB,MAAM,uBAIxC;IAEF,QAAQ,aAAc,MAAM,UAK1B;IAEF,OAAO,CAAC,QAAQ,CAAe;IAE/B,mBAAmB,QAAa,OAAO,CAAC,OAAO,CAAC,CAe9C;IAEF,uBAAuB,QAAa,OAAO,CAAC,MAAM,CAAC,CAsBjD;IAEF,qBAAqB,YAAmB,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,CAgB9D;IAEF,kBAAkB,YAAmB,MAAM,mBAUzC;IAEF,cAAc,OAAc,MAAM,wBAehC;IAEF,aAAa,aAAoB,MAAM,wBAgBrC;IAEF,iBAAiB,OAAc,MAAM;;;OAcnC;IAEF,SAAS,YAAmB,MAAM,YAAY,MAAM,qBAqBlD;IAEF,SAAS,+BAuCP;IAEF,YAAY,+BAeV;IAEF,MAAM,CAAC,YAAY,SAAgB,QAAQ,mBAyBzC;IAEF,MAAM,CAAC,gBAAgB,YAAmB,MAAM,YAAW,MAAM,cAAgC,MAAM,iCA0BrG;IAEF,QAAQ;cAMkB,MAAM;gBAAU,MAAM;eAAS,MAAM;SAC7D;IAEF,WAAW,OAAc,MAAM,kBAO7B;CACH"}
@@ -1,2 +1,2 @@
1
- "use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),n=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime"),require("react"),require("../_virtual/index.js"),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");let o="https://codicent.com/",i="-";const a=()=>void 0!==window.Codicent&&(window.Codicent.init({token:i,baseUrl:o}),!0);let s=a();if(!s){const t=setInterval((()=>{s=a(),s&&clearInterval(t)}),100)}class r{constructor(t){this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const e=new n.default(t.content).content.split("\n"),o=e[0],i=e.slice(1).join("\n");return{id:t.id,title:o,content:i}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.sendMessage=(t,e)=>window.Codicent.postMessage({message:`@${this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e)=>window.Codicent.getChatReply3({message:t,codicent:this.codicent,messageId:e}),this.getMessagesFast=async(t,e,n=100,i=void 0)=>{const a=await fetch(`${o}app/AppGetMessages`,{method:"POST",headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:n})});if(!a.ok)throw a.status,new Error(`${a.statusText}`);let s=await a.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),i){const t=await this.getPublicFlow(i);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let n=[];for(const e of t){const t=await window.Codicent.getMessages({search:`@${this.codicent} #${e}`,length:10});"chat"===e&&t.forEach((t=>t.content=`#chat\n${t.content}`)),n=n.concat(t)}if(e)try{const t=await this.getPublicFlow(e);n=n.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return n=n.filter(((t,e,n)=>e===n.findIndex((e=>e.id===t.id)))),n.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),n},this.registerUser=async(t,e,n,i)=>{const a=await fetch(`${o}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${i}`]],body:JSON.stringify({nickname:t,email:e,userId:n})});if(!a.ok)return"";const s=await a.text();return window.Codicent.init({token:i,baseUrl:o}),s},this.loginUser=async(t,e)=>{try{const n=await fetch(`${o}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!n.ok)return 404===n.status||400===n.status||401===n.status?null:"";const i=await n.text();return this.setToken(i),i}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${o}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${o}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=(await t.json()).filter(((t,e,n)=>e===n.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))));return e}catch(t){return console.warn("Error fetching apps:",t),null}},this.cloneProject=async(t,e)=>{const n=await fetch(`${o}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!n.ok)throw n.status,new Error(`${n.statusText}`);let i=await n.json();if(i){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(i=!1)}catch{i=!1}if(i){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(i=!1)}catch{i=!1}}}return i},this.getNickname=async()=>{try{const t=i.split(".")[1],e=atob(t),n=JSON.parse(e),a=n.sub||n.userId,s=await fetch(`${o}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!s.ok)throw 401===s.status?new Error("Unauthorized"):new Error(`${s.statusText}`);return await s.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),n=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==n&&(console.log("updating instructions",n),await window.Codicent.postMessage({message:n,type:"text",parentId:e[0].id})):(console.log("new instructions",n),await window.Codicent.postMessage({message:n,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const n=await fetch(`${o}/app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!n.ok)throw 401===n.status?new Error("Unauthorized"):new Error(`${n.statusText}`);const i=await n.json(),{email:a,picture:s,description:r,followers:c,properties:h}=i;return{nickname:t,email:a,name:r,picture:s,followers:c,properties:h}},this.updateUserInfo=async({nickname:t,email:e,name:n,picture:i})=>{const a=await fetch(`${o}/app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:n,picture:i,description:""})});if(!a.ok)throw a.status,new Error(`${a.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const n=await fetch(`${o}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!n.ok||(console.warn(`requestInvite() => ${n.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const n=await fetch(`${o}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!n.ok||(console.warn(`updateMembersAccess() => ${n.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.setToken=t=>{i=t,i&&window.Codicent.init({token:i,baseUrl:o})},this.getToken=()=>i,this.checkPurchaseStatus=async()=>{const t=await fetch(`${o}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${o}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=await fetch(`${o}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({priceId:t,successUrl:window.location.href,cancelUrl:window.location.href})});if(!e.ok)throw new Error("Failed to create checkout session");const{id:n}=await e.json();return n},this.redirectToCheckout=async t=>{const n=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!n)throw new Error("Stripe failed to load");const o=await this.createCheckoutSession(t),{error:i}=await n.redirectToCheckout({sessionId:o});if(i)throw new Error(i.message)},this.getChatHistory=async t=>{const e=await fetch(`${o}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let n=await e.json();return n=n.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),n},this.getPublicFlow=async t=>{const e=await fetch(`${o}/app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const n=await e.json();return n.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n},this.getMessageContent=async t=>{const e=await fetch(`${o}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const n={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},i=await fetch(`${o}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(n)});if(!i.ok)throw new Error(`${i.statusText||"Failed to post log message!"}`);return(await i.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){return await this.cloneProject(this.options.APP_TEMPLATE,e)?e:null}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await fetch(`${o}app/GetForms?codicent=${this.codicent}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${o}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.codicent="",this.options=t}}t=r,r.getImageUrl=(t,e)=>`${o}app/GetImage?fileId=${t}&width=${e}`,r.getFileUrl=(t,e)=>`${o}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,r.downloadFile=async e=>{fetch(t.getFileUrl(e.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((t=>{const n=window.URL.createObjectURL(t),o=document.createElement("a");o.style.display="none",o.href=n,o.download=e.filename,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",n)=>{const i=await fetch(`${o}app/GetAi2ChatReply?message=${t}&project=${e}${n?"&messageId="+n:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},exports.CodicentService=r;
1
+ "use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),o=require("../utils/MessageContent.js");require("../node_modules/tinycolor2/esm/tinycolor.js"),require("react/jsx-runtime"),require("react"),require("../_virtual/index.js"),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");let n="https://codicent.com/",i="-";const a=()=>void 0!==window.Codicent&&(window.Codicent.init({token:i,baseUrl:n}),!0);let s=a();if(!s){const t=setInterval((()=>{s=a(),s&&clearInterval(t)}),100)}class r{constructor(t){this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const e=new o.default(t.content).content.split("\n"),n=e[0],i=e.slice(1).join("\n");return{id:t.id,title:n,content:i}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.sendMessage=(t,e)=>window.Codicent.postMessage({message:`@${this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e)=>window.Codicent.getChatReply3({message:t,codicent:this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,i=void 0)=>{const a=await fetch(`${n}app/AppGetMessages`,{method:"POST",headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:o})});if(!a.ok)throw a.status,new Error(`${a.statusText}`);let s=await a.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),i){const t=await this.getPublicFlow(i);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let o=[];for(const e of t){const t=await window.Codicent.getMessages({search:`@${this.codicent} #${e}`,length:10});"chat"===e&&t.forEach((t=>t.content=`#chat\n${t.content}`)),o=o.concat(t)}if(e)try{const t=await this.getPublicFlow(e);o=o.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return o=o.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),o.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),o},this.registerUser=async(t,e,o,i)=>{const a=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${i}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!a.ok)return"";const s=await a.text();return window.Codicent.init({token:i,baseUrl:n}),s},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status||401===o.status?null:"";const i=await o.text();return this.setToken(i),i}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=(await t.json()).filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))));return e}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let i=await o.json();if(i){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(i=!1)}catch{i=!1}if(i){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(i=!1)}catch{i=!1}}}return i},this.getNickname=async()=>{try{const t=i.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,s=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!s.ok)throw 401===s.status?new Error("Unauthorized"):new Error(`${s.statusText}`);return await s.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}/app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?new Error("Unauthorized"):new Error(`${o.statusText}`);const i=await o.json(),{email:a,picture:s,description:r,followers:c,properties:h}=i;return{nickname:t,email:a,name:r,picture:s,followers:c,properties:h}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:i})=>{const a=await fetch(`${n}/app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:i,description:""})});if(!a.ok)throw a.status,new Error(`${a.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.setToken=t=>{i=t,i&&window.Codicent.init({token:i,baseUrl:n})},this.getToken=()=>i,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({priceId:t,successUrl:window.location.href,cancelUrl:window.location.href})});if(!e.ok)throw new Error("Failed to create checkout session");const{id:o}=await e.json();return o},this.redirectToCheckout=async t=>{const o=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(t),{error:i}=await o.redirectToCheckout({sessionId:n});if(i)throw new Error(i.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}/app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},i=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!i.ok)throw new Error(`${i.statusText||"Failed to post log message!"}`);return(await i.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(!await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return null}return e}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await fetch(`${n}app/GetForms?codicent=${this.codicent}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.codicent="",this.options=t}}t=r,r.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,r.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,r.downloadFile=async e=>{fetch(t.getFileUrl(e.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((t=>{const o=window.URL.createObjectURL(t),n=document.createElement("a");n.style.display="none",n.href=o,n.download=e.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",o)=>{const i=await fetch(`${n}app/GetAi2ChatReply?message=${t}&project=${e}${o?"&messageId="+o:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()},exports.CodicentService=r;
2
2
  //# sourceMappingURL=codicent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codicent.js","sources":["../../../../src/services/codicent.ts"],"sourcesContent":[null],"names":["_a","baseUrl","token","initializeCodicent","window","Codicent","init","initialized","setInterval","clearInterval","initInterval","CodicentService","constructor","options","this","getAppTheme","datas","getDataMessages","tags","codicent","length","data","error","console","async","appButtons","BUTTON_TAG","map","d","sort","a","b","title","getAppTasks","getMessages","search","m","rows","MessageContent","default","content","split","prompt","slice","join","id","getAppPrompts","uploadFile","filename","formData","upload","getFileInfo","fileId","sendMessage","message","parentId","postMessage","type","chat","messageId","getChatReply3","getMessagesFast","publicCodicent","undefined","response","fetch","method","headers","getToken","body","JSON","status","Error","statusText","messages","json","forEach","createdAt","Date","parse","publicMessages","getPublicFlow","concat","getTime"],"mappings":"iBA4BAA,wdAGEC,0BACAC,EAAO,IACP,MAAAC,EAAW,SAAuB,IAARC,OAAAC,WAAaD,OAAAC,SAAAC,KAAA,CACvCJ,QAAkB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YAAA,CAAAF,QAAA,IAAAxC,KAAAK,YAAAmC,IAAAG,KAAA,OAAAF,aAEFzC,KAAA4C,KAAwC,CAAAJ,EAAAK,IAA2BvD,OAAAC,SAAAuD,cAejE,CAAAN,UAAAnC,SAAAL,KAAAK,SAAAwC,cAEY7C,KAAA+C,gBAvEiBrC,MAuEGN,EAAAiB,EAAAf,EAAA,IAAA0C,OAAAC,KAElC,MAAAC,QAAuCC,MAAA,GAAiBhE,sBAetD,CAEciE,OAAA,OAMRC,QAAc,CAON,CAAe,gBAAA,UAAArD,KAAAsD,cAE/B,CAAA,eAAgC,oCAyChCC,KAAAC,eAAwC,CAAMpD,OAAAC,SAAUL,KAACK,SAgBvDgB,SAAAf,aAcY,IAAA4C,KAiDZ,MAhCWA,EAAAO,OAgCX,IAAAC,MAAA,GAAAR,EAAAS,cAyBF,IAuBEC,QAAAV,EAAAW,OAyEM,GAvERD,EAeEE,SAAAxC,IAEKA,EAAAyC,UAA4B,IAAAC,KAAAA,KAyBjCC,MAAA3C,EAAAyC,WAAA,IA6BMf,EAAA,CAMwB,MAAAkB,QAAAlE,KAAAmE,cAAAnB,GAAUY,EAAMA,EAAAQ,OAAAF,GAAeN,EAAA7C,MAAA,CAAAC,EAAAC,IAAAA,EAAA8C,UAAAM,UAAArD,EAAA+C,UAAAM,WAC7D,CAES,OAAAT"}
1
+ {"version":3,"file":"codicent.js","sources":["../../../../src/services/codicent.ts"],"sourcesContent":[null],"names":["_a","baseUrl","token","initializeCodicent","window","Codicent","init","initialized","setInterval","clearInterval","initInterval","CodicentService","constructor","options","this","getAppTheme","datas","getDataMessages","tags","codicent","length","data","error","console","getAppButtons","async","appButtons","BUTTON_TAG","map","d","sort","a","b","title","getAppTasks","getMessages","search","m","rows","MessageContent","content","split","prompt","slice","join","id","getAppPrompts","uploadFile","filename","formData","upload","getFileInfo","fileId","sendMessage","message","parentId","postMessage","type","chat","messageId","getChatReply3","getMessagesFast","publicCodicent","undefined","response","fetch","method","headers","getToken","body","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AM,CAAC,CAAC;IACpD,eAAe,EAAE,eAAe,CAAC;IACjC,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAChF;AAED,QAAA,MAAM,YAAY,UAAW,qBAAqB,KAAG,YAuOpD,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -1,2 +1,2 @@
1
- import{useState as o,useMemo as e,useEffect as t}from"react";import{CodicentService as s}from"../services/codicent.js";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"react/jsx-runtime";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{getConfigValue as n}from"../config/index.js";import"../stores/chatStore.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.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"./useLocalization.js";import"./useAppStyles.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"../pages/AppFrame.js";import"../pages/Snap.js";import"../pages/Search.js";import"../pages/Login.js";import"../pages/CrmPage.js";import"../pages/ImageView.js";import"../pages/FormInvite.js";import"../pages/FormAccept.js";import"../pages/Sales.js";const i=i=>{const{isAuthenticated:r,getAccessTokenSilently:p,user:a,isLoading:m,logout:c,getAccessTokenWithPopup:l,loginWithRedirect:g}=i,[j,u]=o(null),[E,P]=o(void 0),[T,_]=o(null),[d,C]=o(""),A=e((()=>new s({API_BASE_URL:n("API_BASE_URL"),APP_LOG_CODICENT:n("APP_LOG_CODICENT"),APP_LOG_TOKEN:n("APP_LOG_TOKEN"),APP_NAME:n("APP_NAME"),APP_PREFIX:n("APP_PREFIX"),APP_TEMPLATE:n("APP_TEMPLATE"),BUTTON_TAG:n("BUTTON_TAG"),STRIPE_PUBLIC_KEY:n("STRIPE_PUBLIC_KEY"),SUBSCRIPTION_NEEDED:n("SUBSCRIPTION_NEEDED"),USER_PREFIX:n("USER_PREFIX")})),[]);t((()=>{m||(async()=>{try{const o=await p({});console.debug("CODICENT: ACCESS TOKEN",o),u(o)}catch(o){console.debug("CODICENT: Failed to get access token",o);const e=o;if(e&&"object"==typeof e&&"error"in e&&"login_required"===e.error)console.warn("CODICENT: Login required"),I();else if(e&&"object"==typeof e&&"error"in e&&"consent_required"===e.error)try{const o=await l();if(!o)return void _("Failed to get access token: no token from auth0 with popup");console.log("CODICENT: GOT ACCESS TOKEN"),u(o)}catch(o){console.warn("CODICENT: Failed to get access token with popup",o),I()}else _("Failed to get access token: "+(e.message?.toString()||e.toString())),console.log("CODICENT: ACCESS TOKEN ERROR",e)}})().then((()=>{}))}),[r,l,p,g,m]),t((()=>{if(a&&a.sub&&j&&void 0===E){let o=!0;return A.loginUser(a.sub,j).then((e=>{o&&(null===e?P(!1):""===e?_("Kontrollera internetanslutningen och försök igen."):(A.setToken(j),A.getNickname().then(C),P(!0)))})).catch((()=>{o&&(_("Ett fel uppstod. Försök igen senare."),P(!1))})),()=>{o=!1}}}),[a,j,E,A]);const I=()=>{A.logout(),u(null),_(null),P(void 0),C(""),c({logoutParams:{returnTo:n("AUTH_REDIRECT_URL")}})};return{isAuthenticated:r,isRegistered:E,accessToken:j,authError:T,isLoading:m,user:a,nickname:d,logout:I,registerUser:async o=>{const e=await A.registerUser(o,a.email,a.sub,j);return e&&(A.setToken(j),P(!0)),e},codicentService:A,loginWithRedirect:g}};export{i as default};
1
+ import{useState as o,useMemo as e,useEffect as t}from"react";import{CodicentService as s}from"../services/codicent.js";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"react/jsx-runtime";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{getConfigValue as n}from"../config/index.js";import"../stores/chatStore.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.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"./useLocalization.js";import"./useAppStyles.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"../pages/AppFrame.js";import"../pages/Snap.js";import"../pages/Search.js";import"../pages/Login.js";import"../pages/CrmPage.js";import"../pages/ImageView.js";import"../pages/FormInvite.js";import"../pages/FormAccept.js";import"../pages/Sales.js";const i=i=>{const{isAuthenticated:r,getAccessTokenSilently:p,user:a,isLoading:m,logout:c,getAccessTokenWithPopup:l,loginWithRedirect:g}=i,[j,E]=o(null),[u,T]=o(void 0),[_,P]=o(null),[d,A]=o(""),C=e((()=>new s({API_BASE_URL:n("API_BASE_URL"),APP_LOG_CODICENT:n("APP_LOG_CODICENT"),APP_LOG_TOKEN:n("APP_LOG_TOKEN"),APP_NAME:n("APP_NAME"),APP_PREFIX:n("APP_PREFIX"),APP_TEMPLATE:n("APP_TEMPLATE"),BUTTON_TAG:n("BUTTON_TAG"),STRIPE_PUBLIC_KEY:n("STRIPE_PUBLIC_KEY"),SUBSCRIPTION_NEEDED:n("SUBSCRIPTION_NEEDED"),USER_PREFIX:n("USER_PREFIX"),ANONYMOUS_TOKEN:n("ANONYMOUS_TOKEN")})),[]);t((()=>{m||(async()=>{try{const o=await p({});console.debug("CODICENT: ACCESS TOKEN",o),E(o)}catch(o){console.debug("CODICENT: Failed to get access token",o);const e=o;if(e&&"object"==typeof e&&"error"in e&&"login_required"===e.error)console.warn("CODICENT: Login required"),I();else if(e&&"object"==typeof e&&"error"in e&&"consent_required"===e.error)try{const o=await l();if(!o)return void P("Failed to get access token: no token from auth0 with popup");console.log("CODICENT: GOT ACCESS TOKEN"),E(o)}catch(o){console.warn("CODICENT: Failed to get access token with popup",o),I()}else P("Failed to get access token: "+(e.message?.toString()||e.toString())),console.log("CODICENT: ACCESS TOKEN ERROR",e)}})().then((()=>{}))}),[r,l,p,g,m]),t((()=>{if(a&&a.sub&&j&&void 0===u){let o=!0;return C.loginUser(a.sub,j).then((e=>{o&&(null===e?T(!1):""===e?P("Kontrollera internetanslutningen och försök igen."):(C.setToken(j),C.getNickname().then(A),T(!0)))})).catch((()=>{o&&(P("Ett fel uppstod. Försök igen senare."),T(!1))})),()=>{o=!1}}}),[a,j,u,C]);const I=()=>{C.logout(),E(null),P(null),T(void 0),A(""),c({logoutParams:{returnTo:n("AUTH_REDIRECT_URL")}})};return{isAuthenticated:r,isRegistered:u,accessToken:j,authError:_,isLoading:m,user:a,nickname:d,logout:I,registerUser:async o=>{const e=await C.registerUser(o,a.email,a.sub,j);return e&&(C.setToken(j),T(!0)),e},codicentService:C,loginWithRedirect:g}};export{i as default};
2
2
  //# sourceMappingURL=useAuthState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthState.js","sources":["../../../../src/hooks/useAuthState.ts"],"sourcesContent":[null],"names":["useAuthState","isAuthenticated","getAccessTokenSilently","user","isLoading","logout","getAccessTokenWithPopup","loginWithRedirect","auth0","accessToken","setAccessToken","useState","isRegistered","setIsRegistered","undefined","authError","setAuthError","nickname","setNickname","codicentService","useMemo","CodicentService","API_BASE_URL","getConfigValue","APP_LOG_CODICENT","APP_LOG_TOKEN","APP_NAME","APP_PREFIX","APP_TEMPLATE"],"mappings":"unDAaiB,MAAAA,MACf,MAAAC,gBAAAA,EAAwBC,uBAAAA,EAAUC,KAAAA,EAAAC,UAAAA,EAAAC,OAAAA,EAAAC,wBAAAA,EAAAC,kBAAAA,GAAAC,GAClCC,EAAsBC,GAAKC,EAAA,OAC3BC,EAAoBC,GAAKF,OAAAG,IAChBC,EAASC,GAACL,EAAA,OAKXM,EAASC,GAAAP,EAAA,IACXQ,EAAaC,GAAA,IAAA,IAAAC,EAAA,CACPC,aAAGC,kBACAC,mBAAkB,oBACjCC,cAAmBF,EAA+B,iBACnDG,SAAAH,EAAA,YAEDI,WAAkBJ,EAAA,cAwOlBK,eAA4B"}
1
+ {"version":3,"file":"useAuthState.js","sources":["../../../../src/hooks/useAuthState.ts"],"sourcesContent":[null],"names":["useAuthState","isAuthenticated","getAccessTokenSilently","user","isLoading","logout","getAccessTokenWithPopup","loginWithRedirect","auth0","accessToken","setAccessToken","useState","isRegistered","setIsRegistered","undefined","authError","setAuthError","nickname","setNickname","codicentService","useMemo","CodicentService","API_BASE_URL","getConfigValue","APP_LOG_CODICENT","APP_LOG_TOKEN","APP_NAME","APP_PREFIX","APP_TEMPLATE"],"mappings":"unDAaiB,MAAAA,MACf,MAAAC,gBAAAA,EAAwBC,uBAAAA,EAAUC,KAAAA,EAAAC,UAAAA,EAAAC,OAAAA,EAAAC,wBAAAA,EAAAC,kBAAAA,GAAAC,GAClCC,EAAsBC,GAAKC,EAAA,OAC3BC,EAAoBC,GAAKF,OAAAG,IAChBC,EAASC,GAACL,EAAA,OAKXM,EAASC,GAAAP,EAAA,IACXQ,EAAaC,GAAA,IAAA,IAAAC,EAAA,CACPC,aAAGC,kBACAC,mBAAkB,oBACjCC,cAAmBF,EAA+B,iBACnDG,SAAAH,EAAA,YAEDI,WAAkBJ,EAAA,cAyOlBK,eAA4B"}
@@ -1,2 +1,2 @@
1
- import{commonjsGlobal as t,getDefaultExportFromCjs as r}from"../../../_virtual/_commonjsHelpers.js";import"../../style-to-object/cjs/index.js";import"./utilities.js";import{__exports as e}from"../../../_virtual/index4.js";import{__exports as i}from"../../../_virtual/utilities.js";var o=(t&&t.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(e),s=i;function a(t,r){var e={};return t&&"string"==typeof t?((0,o.default)(t,(function(t,i){t&&i&&(e[(0,s.camelCase)(t,r)]=i)})),e):e}a.default=a;var u=r(a);export{u as default};
1
+ import{getDefaultExportFromCjs as t,commonjsGlobal as r}from"../../../_virtual/_commonjsHelpers.js";import"../../style-to-object/cjs/index.js";import"./utilities.js";import{__exports as e}from"../../../_virtual/index4.js";import{__exports as i}from"../../../_virtual/utilities.js";var o=(r&&r.__importDefault||function(t){return t&&t.__esModule?t:{default:t}})(e),s=i;function a(t,r){var e={};return t&&"string"==typeof t?((0,o.default)(t,(function(t,i){t&&i&&(e[(0,s.camelCase)(t,r)]=i)})),e):e}a.default=a;var u=t(a);export{u as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CrmPage.d.ts","sourceRoot":"","sources":["../../../src/pages/CrmPage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAA+B,MAAM,UAAU,CAAC;AAuDzE,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CA8QzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"CrmPage.d.ts","sourceRoot":"","sources":["../../../src/pages/CrmPage.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAA+B,MAAM,UAAU,CAAC;AAuDzE,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CAoRzD,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useState as t,useRef as n,useCallback as r,useEffect as i,useMemo as a}from"react";import{CodicentService as s}from"../services/codicent.js";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/Spinner.js";import m from"../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 p from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as l}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 c from"../components/MessageInput.js";import d from"../components/UploadFile.js";import"../components/SnapFooter.js";import"../components/Profile.js";import"../components/MessageItem.js";import"../components/Content.js";import g from"../components/AiInput.js";import"../components/SearchBox.js";import"../components/HtmlView.js";import"../components/Footer.js";import{Page as u}from"../components/Page.js";import"./AppFrame.js";import"./Snap.js";import"./Search.js";import"./Login.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"../stores/chatStore.js";import f from"../hooks/useLocalization.js";import"../hooks/useAppStyles.js";import j from"../hooks/useToaster.js";import{useSearchParams as h}from"react-router-dom";import{l as v}from"../node_modules/lodash/lodash.js";import{makeStyles as k}from"../node_modules/@griffel/react/makeStyles.esm.js";import{shorthands as x}from"../node_modules/@griffel/core/index.esm.js";import{tokens as S}from"../node_modules/@fluentui/tokens/lib/tokens.js";const $=k({main:{flexGrow:1,...x.padding("10px"),overflowY:"auto"},container:{maxWidth:"640px",margin:"0 auto",backgroundPosition:"calc(50% + 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"100%"},root:{height:"100%"},item:{height:"auto",width:"auto",flexShrink:1,marginBottom:"1rem"},chat:{flexGrow:1,boxSizing:"border-box",overflow:"hidden",border:"none"},attachmentBar:{display:"none"},iconButton:{width:"24px",height:"24px"},imageCard:{alignContent:"center",borderRadius:S.borderRadiusLarge,height:"240px",textAlign:"left",position:"relative"}}),b=({state:k})=>{const x=$(),{t:S}=f(),[b,w]=t(!1),T=n(null),y=n(null),C=n(null),[_]=t(null),[U,I]=t([]),{service:M}=k,[E,F]=h(),[A,K]=t(""),[P,V]=t(void 0),[R,L]=t(void 0),[O,B]=t(void 0),[N,D]=t(void 0),G=j(),H=[S("Kundinteraktion"),S("Försäljningsaktivitet"),S("Offertskapande"),S("Att-göra-uppgift")],z=[S("Kund 1"),S("Kund 2"),S("Kund 3")],X=[S("Kontakt 1"),S("Kontakt 2"),S("Kontakt 3")],Y=e=>`Vilken typ av CRM-aktivitet är det? Välj från ${H[0]}, ${H[1]}, ${H[2]} eller ${H[3]}. Svara bara med en av dessa, ingen annan text.\nTEXT:\n\n${e}`,J=e=>`Vilken kund är det? Välj från ${z[0]}, ${z[1]} eller ${z[2]}. Svara med en av dessa om de matchar, annars extrahera nytt kundnamn från texten, ingen annan text.\nTEXT:\n\n${e}`,W=e=>`Vilken kontakt är det? Svara med kontaktnamn från texten om det går, ingen annan text.\nTEXT:\n\n${e}`,q=r((e=>{for(const o of e)M.getFileInfo(o).then((e=>{I((o=>[...o,e]))}))}),[M,I]),Q=r((e=>{const o=new FormData;o.append("file",e),M.uploadFile(e.name,o).then((e=>{q([e])})).catch((()=>{G.notify(S("Error"),S("Error uploading pasted image"),"")}))}),[M,q,G,S]),Z=e=>{w(e)};i((()=>{const e=E.get("text"),o=E.get("url");e&&(K(e),E.delete("text")),o&&(E.delete("url"),K(((e||"")+" "+o).trim())),F(E,{replace:!0})}),[E,F,K,M,q]);const ee=r((async e=>{if(!e)return;const o=await M.chat(Y(e));if(o){const e=new p(o.content);console.log("typeMsg",e.content),V(e.content)}const t=await M.chat(J(e));if(t){const e=new p(t.content);console.log("customerMsg",e.content),L(e.content)}const n=await M.chat(W(e));if(n){const e=new p(n.content);console.log("contactMsg",e.content),B(e.content)}}),[M]),oe=a((()=>v.debounce(ee,1e3)),[ee]);return i((()=>()=>{oe.cancel()}),[oe]),e(u,{hideHeader:!0,children:o("div",{className:x.container,style:{backgroundImage:`url(${l("COMPOSE_BACKGROUND_IMAGE_URL")})`},children:[e(m,{title:l("APP_SAVE_TITLE")?S(l("APP_SAVE_TITLE")):S("Spara")}),e(c,{defaultText:A,onSend:e=>{if(P===H[3])e+=`\nTYPE: ${P||""}\nCUSTOMER: ${R||""}\nCONTACT: ${O||""}`,e=`${e+=`\nSALESPERSON: ${k.context.name||k.context.user?.email||k.context.nickname||"-"}`}${_?" "+_:""}${P===H[3]?" #todo ":""}${U.map((e=>`#file:${e.id}`)).join(" ")}`;else{const o=JSON.stringify({type:P,customer:R,contact:O,message:e.replace("#log ",""),salesperson:k.context.name||k.context.user?.email||k.context.nickname||"-"});e=`${e="#crm #data\n"+o}${_?" "+_:""}${U.length>0?"\n":""}${U.map((e=>`#file:${e.id}`)).join(" ")}`}M.sendMessage(e).then((()=>{G.notify(S("Meddelande"),S("Meddelandet är sparat."),"")}))},files:U,onFilesChange:I,isUploading:b,onUploadImage:()=>{y.current?.triggerUpload()},onUploadCamera:()=>{C.current?.triggerUpload()},getImageUrl:s.getImageUrl,hasLocation:!!_,disableSend:!0,rows:9,placeholder:S("Beskriv CRM-aktivitet här..."),onChange:e=>{D(e),oe(e)},onImagePasted:Q}),e(g,{title:S("Typ"),id:"crm-type",options:H,placeholder:S("Typ av aktivitet..."),value:P,onChangeValue:V,prompt:Y(N||""),service:M}),e(g,{title:S("Kund"),id:"crm-customer",options:z,placeholder:S("Kund..."),value:R,onChangeValue:L,prompt:J(N||""),service:M}),e(g,{title:S("Kontakt"),id:"crm-contact",options:X,placeholder:S("Kontaktperson..."),value:O,onChangeValue:B,prompt:W(N||""),service:M}),e(d,{ref:T,onFileUploaded:q,onUploading:Z,multiple:!0,codicentService:M}),e(d,{codicentService:M,ref:y,onFileUploaded:q,onUploading:Z,multiple:!0,accept:"image/*"}),e(d,{codicentService:M,ref:C,onFileUploaded:q,onUploading:Z,multiple:!0,accept:"image/*",capture:"environment"})]})})};export{b as CrmPage,b as default};
1
+ import{jsx as o,jsxs as e}from"react/jsx-runtime";import{useState as t,useRef as r,useCallback as i,useEffect as n}from"react";import{CodicentService as s}from"../services/codicent.js";import"../components/Markdown.js";import"../components/Textarea.js";import"../components/Button.js";import"../components/Spinner.js";import a from"../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 m}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 p from"../components/MessageInput.js";import l from"../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{Page as c}from"../components/Page.js";import"./AppFrame.js";import"./Snap.js";import"./Search.js";import"./Login.js";import"./ImageView.js";import"./FormInvite.js";import"./FormAccept.js";import"./Sales.js";import"../stores/chatStore.js";import d from"../hooks/useLocalization.js";import"../hooks/useAppStyles.js";import g from"../hooks/useToaster.js";import{useSearchParams as j}from"react-router-dom";import{makeStyles as u}from"../node_modules/@griffel/react/makeStyles.esm.js";import{shorthands as f}from"../node_modules/@griffel/core/index.esm.js";import{tokens as h}from"../node_modules/@fluentui/tokens/lib/tokens.js";const v=u({main:{flexGrow:1,...f.padding("10px"),overflowY:"auto"},container:{maxWidth:"640px",margin:"0 auto",backgroundPosition:"calc(50% + 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"100%"},root:{height:"100%"},item:{height:"auto",width:"auto",flexShrink:1,marginBottom:"1rem"},chat:{flexGrow:1,boxSizing:"border-box",overflow:"hidden",border:"none"},attachmentBar:{display:"none"},iconButton:{width:"24px",height:"24px"},imageCard:{alignContent:"center",borderRadius:h.borderRadiusLarge,height:"240px",textAlign:"left",position:"relative"}}),x=({state:u})=>{const f=v(),{t:h}=d(),[x,b]=t(!1),S=r(null),w=r(null),_=r(null),[I]=t(null),[U,k]=t([]),{service:F}=u,[C,y]=j(),[A,M]=t("");t(void 0),t(void 0),t(void 0);const[P,T]=t(void 0),E=g(),B=i((o=>{for(const e of o)F.getFileInfo(e).then((o=>{k((e=>[...e,o]))}))}),[F,k]),L=i((o=>{const e=new FormData;e.append("file",o),F.uploadFile(o.name,e).then((o=>{B([o])})).catch((()=>{E.notify(h("Error"),h("Error uploading pasted image"),"")}))}),[F,B,E,h]),R=o=>{b(o)};n((()=>{const o=C.get("text"),e=C.get("url");o&&(M(o),C.delete("text")),e&&(C.delete("url"),M(((o||"")+" "+e).trim())),y(C,{replace:!0})}),[C,y,M,F,B]);return o(c,{hideHeader:!0,children:e("div",{className:f.container,style:{backgroundImage:`url(${m("COMPOSE_BACKGROUND_IMAGE_URL")})`},children:[o(a,{title:m("APP_SAVE_TITLE")?h(m("APP_SAVE_TITLE")):h("Spara")}),o(p,{defaultText:A,onSend:o=>{o=`${o="#crm\n"+o.replace("#log ","")}${I?" "+I:""}${U.length>0?"\n":""}${U.map((o=>`#file:${o.id}`)).join(" ")}`,F.sendMessage(o).then((()=>{E.notify(h("Meddelande"),h("Meddelandet är sparat."),"")}))},files:U,onFilesChange:k,isUploading:x,onUploadImage:()=>{w.current?.triggerUpload()},onUploadCamera:()=>{_.current?.triggerUpload()},getImageUrl:s.getImageUrl,hasLocation:!!I,disableSend:!0,rows:9,placeholder:h("Beskriv CRM-aktivitet här..."),onChange:o=>{T(o)},onImagePasted:L}),o(l,{ref:S,onFileUploaded:B,onUploading:R,multiple:!0,codicentService:F}),o(l,{codicentService:F,ref:w,onFileUploaded:B,onUploading:R,multiple:!0,accept:"image/*"}),o(l,{codicentService:F,ref:_,onFileUploaded:B,onUploading:R,multiple:!0,accept:"image/*",capture:"environment"})]})})};export{x as CrmPage,x as default};
2
2
  //# sourceMappingURL=CrmPage.js.map
@@ -27,6 +27,7 @@ export interface CodicentServiceOptions {
27
27
  STRIPE_PUBLIC_KEY: string;
28
28
  SUBSCRIPTION_NEEDED: boolean;
29
29
  USER_PREFIX: string;
30
+ ANONYMOUS_TOKEN?: string;
30
31
  }
31
32
  export declare class CodicentService {
32
33
  codicent: string;
@@ -57,6 +58,7 @@ export declare class CodicentService {
57
58
  logout: () => void;
58
59
  isRegistered: () => boolean;
59
60
  getApps: () => Promise<AppInfo[] | null>;
61
+ addFollower: (nickname: string, followerNickname: string) => Promise<boolean>;
60
62
  cloneProject: (project: string, newProject: string) => Promise<boolean>;
61
63
  getNickname: () => Promise<string>;
62
64
  getChatInstructions: () => Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AA4BA,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE;QAAE,aAAa,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACvC,UAAU,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC/C;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,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cAAc,OAAc,MAAM,wBAehC;IAEF,aAAa,aAAoB,MAAM,wBAgBrC;IAEF,iBAAiB,OAAc,MAAM;;;OAcnC;IAEF,SAAS,YAAmB,MAAM,YAAY,MAAM,qBAqBlD;IAEF,SAAS,+BAuCP;IAEF,YAAY,+BAeV;IAEF,MAAM,CAAC,YAAY,SAAgB,QAAQ,mBAyBzC;IAEF,MAAM,CAAC,gBAAgB,YAAmB,MAAM,YAAW,MAAM,cAAgC,MAAM,iCA0BrG;IAEF,QAAQ;cAMkB,MAAM;gBAAU,MAAM;eAAS,MAAM;SAC7D;IAEF,WAAW,OAAc,MAAM,kBAO7B;CACH"}
@@ -1,2 +1,2 @@
1
- import{loadStripe as t}from"../node_modules/@stripe/stripe-js/dist/index.js";import e from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../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";var o;let n="https://codicent.com/",i="-";const a=()=>void 0!==window.Codicent&&(window.Codicent.init({token:i,baseUrl:n}),!0);let s=a();if(!s){const t=setInterval((()=>{s=a(),s&&clearInterval(t)}),100)}class r{constructor(o){this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const o=new e(t.content).content.split("\n"),n=o[0],i=o.slice(1).join("\n");return{id:t.id,title:n,content:i}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.sendMessage=(t,e)=>window.Codicent.postMessage({message:`@${this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e)=>window.Codicent.getChatReply3({message:t,codicent:this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,i=void 0)=>{const a=await fetch(`${n}app/AppGetMessages`,{method:"POST",headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:o})});if(!a.ok)throw a.status,new Error(`${a.statusText}`);let s=await a.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),i){const t=await this.getPublicFlow(i);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let o=[];for(const e of t){const t=await window.Codicent.getMessages({search:`@${this.codicent} #${e}`,length:10});"chat"===e&&t.forEach((t=>t.content=`#chat\n${t.content}`)),o=o.concat(t)}if(e)try{const t=await this.getPublicFlow(e);o=o.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return o=o.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),o.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),o},this.registerUser=async(t,e,o,i)=>{const a=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${i}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!a.ok)return"";const s=await a.text();return window.Codicent.init({token:i,baseUrl:n}),s},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status||401===o.status?null:"";const i=await o.text();return this.setToken(i),i}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let i=await o.json();if(i){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(i=!1)}catch{i=!1}if(i){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(i=!1)}catch{i=!1}}}return i},this.getNickname=async()=>{try{const t=i.split(".")[1],e=atob(t),o=JSON.parse(e),a=o.sub||o.userId,s=await fetch(`${n}app/GetNickname?userId=${a}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!s.ok)throw 401===s.status?new Error("Unauthorized"):new Error(`${s.statusText}`);return await s.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}/app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?new Error("Unauthorized"):new Error(`${o.statusText}`);const i=await o.json(),{email:a,picture:s,description:r,followers:c,properties:h}=i;return{nickname:t,email:a,name:r,picture:s,followers:c,properties:h}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:i})=>{const a=await fetch(`${n}/app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:i,description:""})});if(!a.ok)throw a.status,new Error(`${a.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.setToken=t=>{i=t,i&&window.Codicent.init({token:i,baseUrl:n})},this.getToken=()=>i,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({priceId:t,successUrl:window.location.href,cancelUrl:window.location.href})});if(!e.ok)throw new Error("Failed to create checkout session");const{id:o}=await e.json();return o},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(e),{error:i}=await o.redirectToCheckout({sessionId:n});if(i)throw new Error(i.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}/app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},i=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!i.ok)throw new Error(`${i.statusText||"Failed to post log message!"}`);return(await i.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){return await this.cloneProject(this.options.APP_TEMPLATE,e)?e:null}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await fetch(`${n}app/GetForms?codicent=${this.codicent}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.codicent="",this.options=o}}o=r,r.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,r.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,r.downloadFile=async t=>{fetch(o.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const o=window.URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.href=o,n.download=t.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",o)=>{const i=await fetch(`${n}app/GetAi2ChatReply?message=${t}&project=${e}${o?"&messageId="+o:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!i.ok)return void i.status;return(await i.json()).content.replace("@codicent-mini","").trim()};export{r as CodicentService};
1
+ import{loadStripe as t}from"../node_modules/@stripe/stripe-js/dist/index.js";import e from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"react/jsx-runtime";import"react";import"../_virtual/index.js";import"../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";var o;let n="https://codicent.com/",a="-";const i=()=>void 0!==window.Codicent&&(window.Codicent.init({token:a,baseUrl:n}),!0);let s=i();if(!s){const t=setInterval((()=>{s=i(),s&&clearInterval(t)}),100)}class r{constructor(o){this.getAppTheme=async()=>{try{const t=await window.Codicent.getDataMessages({tags:["app-theme"],codicent:this.codicent});return t.length>0?t[0].data:null}catch(t){return console.error("Error fetching app theme:",t),null}},this.getAppButtons=async()=>{const t=(await window.Codicent.getDataMessages({tags:[this.options.BUTTON_TAG],codicent:this.codicent})).map((t=>t.data));return t.sort(((t,e)=>t.title>e.title?1:-1)),t},this.getAppTasks=async()=>(await window.Codicent.getMessages({search:`@${this.codicent} #app-task`,length:50})).map((t=>{const o=new e(t.content).content.split("\n"),n=o[0],a=o.slice(1).join("\n");return{id:t.id,title:n,content:a}})),this.getAppPrompts=async()=>(await window.Codicent.getDataMessages({tags:["chatprompt"],codicent:this.codicent})).map((t=>t.data)).map((({title:t,prompt:e})=>({title:t,prompt:e}))),this.uploadFile=async(t,e)=>await window.Codicent.upload(e,t),this.getFileInfo=async t=>await window.Codicent.getFileInfo(t),this.sendMessage=(t,e)=>window.Codicent.postMessage({message:`@${this.codicent} ${t}`,type:"text",parentId:e}),this.chat=(t,e)=>window.Codicent.getChatReply3({message:t,codicent:this.codicent,messageId:e}),this.getMessagesFast=async(t,e,o=100,a=void 0)=>{const i=await fetch(`${n}app/AppGetMessages`,{method:"POST",headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:o})});if(!i.ok)throw i.status,new Error(`${i.statusText}`);let s=await i.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a){const t=await this.getPublicFlow(a);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let o=[];for(const e of t){const t=await window.Codicent.getMessages({search:`@${this.codicent} #${e}`,length:10});"chat"===e&&t.forEach((t=>t.content=`#chat\n${t.content}`)),o=o.concat(t)}if(e)try{const t=await this.getPublicFlow(e);o=o.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return o=o.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id)))),o.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),o},this.registerUser=async(t,e,o,a)=>{const i=await fetch(`${n}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${a}`]],body:JSON.stringify({nickname:t,email:e,userId:o})});if(!i.ok)return"";const s=await i.text();return window.Codicent.init({token:a,baseUrl:n}),s},this.loginUser=async(t,e)=>{try{const o=await fetch(`${n}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!o.ok)return 404===o.status||400===o.status||401===o.status?null:"";const a=await o.text();return this.setToken(a),a}catch(t){return console.warn("Error logging in user:",t),""}},this.nicknameExists=async t=>{const e=await fetch(`${n}app/NicknameExists?nickname=${encodeURIComponent(t)}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"]]});if(!e.ok)return!1;return await e.json()},this.logout=()=>{this.setToken("")},this.isRegistered=()=>null!==localStorage.getItem("codicent_nickname"),this.getApps=async()=>{try{const t=await fetch(`${n}app/AppGetApps`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw t.status,new Error(`${t.statusText}`);const e=await t.json();return e.filter(((t,e,o)=>e===o.findIndex((e=>e.id===t.id))&&(this.options.APP_NAME||t.id.startsWith(this.options.APP_PREFIX))))}catch(t){return console.warn("Error fetching apps:",t),null}},this.addFollower=async(t,e)=>{const o=await fetch(`${n}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText||"Failed to add follower!"}`);return await o.json()},this.cloneProject=async(t,e)=>{const o=await fetch(`${n}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw o.status,new Error(`${o.statusText}`);let a=await o.json();if(a){const t='#data #app-theme \n{\n "textcolor": "#212121",\n "backgroundcolor": "#273044",\n "color": "#ffffff",\n "logo": "https://codicent.com/logo512.png",\n "title": "",\n "themeColor": "#581d71",\n "buttonColor": "#c0c0c0",\n "buttonTextColor": "#000000",\n "font": "Montserrat",\n "welcome": "Hej {{username}}!",\n "chatPlaceholder": "Tjena, Loociz här! Vad vill du?",\n "textPlaceholder": "Skriv det du vill spara, så tar jag (Loociz alltså) hand om det!",\n "transcriptionInstructions": "Tryck på knappen för att start och sedan stoppa ljudinspelning."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}if(a){const t='#data #app-button\n{\n "title": "Ta fram företagsinfo",\n "url": "/#/chat?text=Hej!%20Jag%20vill%20spara%20f%C3%B6retagsinfo.%20Guida%20mig%20steg%20f%C3%B6r%20steg%2C%20ett%20i%20taget%2C%20tills%20vi%20har%20all%20info%20om%20mitt%20f%C3%B6retag.%20Exempel%20p%C3%A5%20data%3A%20f%C3%B6retagsnamn%20eller%20id%C3%A9namn%2C%20org.nr.%2C%20%C3%A4gare%2C%20kontaktinformation%2C%20vision%2C%20aff%C3%A4rsid%C3%A9%2C%20mm."\n}';try{await window.Codicent.postMessage({message:`@${e} ${t}`,type:"text"})||(a=!1)}catch{a=!1}}}return a},this.getNickname=async()=>{try{const t=a.split(".")[1],e=atob(t),o=JSON.parse(e),i=o.sub||o.userId,s=await fetch(`${n}app/GetNickname?userId=${i}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!s.ok)throw 401===s.status?new Error("Unauthorized"):new Error(`${s.statusText}`);return await s.text()}catch{return""}},this.getChatInstructions=async()=>{try{const t=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:1});if(t.length>0)return t[0].content}catch{console.warn("Error fetching chat instructions")}return""},this.updateChatInstructions=async t=>{try{const e=await window.Codicent.getMessages({search:`@${this.codicent} #instructions`,length:100}),o=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==o&&(console.log("updating instructions",o),await window.Codicent.postMessage({message:o,type:"text",parentId:e[0].id})):(console.log("new instructions",o),await window.Codicent.postMessage({message:o,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const o=await fetch(`${n}/app/GetUserInfo?nickname=${t}${e?"&t="+Date.now():""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!o.ok)throw 401===o.status?new Error("Unauthorized"):new Error(`${o.statusText}`);const a=await o.json(),{email:i,picture:s,description:r,followers:c,properties:h}=a;return{nickname:t,email:i,name:r,picture:s,followers:c,properties:h}},this.updateUserInfo=async({nickname:t,email:e,name:o,picture:a})=>{const i=await fetch(`${n}/app/AddOrUpdateUser`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({nickname:t,email:e,name:o,picture:a,description:""})});if(!i.ok)throw i.status,new Error(`${i.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const o=await fetch(`${n}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`requestInvite() => ${o.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const o=await fetch(`${n}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!o.ok||(console.warn(`updateMembersAccess() => ${o.statusText}`),!1)},this.getMembersAccess=async t=>{const e=(await this.getProjectInfo(t,!0)).properties.find((t=>"APP_EDITORS"===t.name));return e&&e.value?e.value.split(","):[]},this.setToken=t=>{a=t,a&&window.Codicent.init({token:a,baseUrl:n})},this.getToken=()=>a,this.checkPurchaseStatus=async()=>{const t=await fetch(`${n}payments/GetPaymentStatus`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!t.ok)throw new Error("Failed to check purchase status");const{isPaid:e}=await t.json();return e},this.checkSubscriptionStatus=async()=>{if(!this.options.SUBSCRIPTION_NEEDED)return"active";const t=await fetch(`${n}payments/GetSubscriptionStatus?t=${Date.now()}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`],["Cache-Control","no-cache, no-store, must-revalidate"],["Pragma","no-cache"],["Expires","0"]]});if(!t.ok)throw new Error("Failed to check subscription status");const{status:e}=await t.json();return e},this.createCheckoutSession=async t=>{const e=await fetch(`${n}payments/CreateCheckoutSession`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]],body:JSON.stringify({priceId:t,successUrl:window.location.href,cancelUrl:window.location.href})});if(!e.ok)throw new Error("Failed to create checkout session");const{id:o}=await e.json();return o},this.redirectToCheckout=async e=>{const o=await t(this.options.STRIPE_PUBLIC_KEY);if(!o)throw new Error("Stripe failed to load");const n=await this.createCheckoutSession(e),{error:a}=await o.redirectToCheckout({sessionId:n});if(a)throw new Error(a.message)},this.getChatHistory=async t=>{const e=await fetch(`${n}api/GetMessageHistory?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get chat history");let o=await e.json();return o=o.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),o},this.getPublicFlow=async t=>{const e=await fetch(`${n}/app/GetPublicFlow?codicent=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!e.ok)throw new Error("Failed to get public flow");const o=await e.json();return o.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),o},this.getMessageContent=async t=>{const e=await fetch(`${n}app/GetMessageContent?id=${t}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(e.ok){const t=await e.json();return{content:t.content,url:t.url}}return{content:"",url:""}},this.logAction=async(t,e)=>{if(!this.options.APP_LOG_CODICENT)return"";const o={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},a=await fetch(`${n}app/AddChatMessage`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.options.APP_LOG_TOKEN}`]],body:JSON.stringify(o)});if(!a.ok)throw new Error(`${a.statusText||"Failed to post log message!"}`);return(await a.json()).id},this.createApp=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.APP_PREFIX}${t}`;if(!await this.nicknameExists(e)){if(!await this.cloneProject(this.options.APP_TEMPLATE,e)){if(this.options.ANONYMOUS_TOKEN)try{const t=this.options.ANONYMOUS_TOKEN.split(".")[1],o=atob(t),n=JSON.parse(o).nickname;if(!await this.addFollower(e,n))throw new Error("Failed to add follower: "+n)}catch(t){console.error("Error extracting adding anonymous follower:",t)}return null}return e}}}catch(t){console.error("Error creating app:",t)}return null},this.findUsername=async()=>{try{for(let t=0;t<50;t++){const t=Math.floor(99999*Math.random())+1,e=`${this.options.USER_PREFIX}${t}`;if(!await this.nicknameExists(e))return e}}catch(t){console.warn("Error finding username:",t)}return null},this.getForms=async()=>{const t=await fetch(`${n}app/GetForms?codicent=${this.codicent}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await t.json()},this.getFormById=async t=>{const e=await fetch(`${n}app/GetFormById?id=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return await e.json()},this.codicent="",this.options=o}}o=r,r.getImageUrl=(t,e)=>`${n}app/GetImage?fileId=${t}&width=${e}`,r.getFileUrl=(t,e)=>`${n}app/DownloadFile?fileId=${t}${e?`&extension=${e}`:""}`,r.downloadFile=async t=>{fetch(o.getFileUrl(t.id)).then((t=>{if(t.headers.forEach(((t,e)=>{console.log(`${e}: ${t}`)})),t.ok)return t.blob();throw new Error("Network response was not ok.")})).then((e=>{const o=window.URL.createObjectURL(e),n=document.createElement("a");n.style.display="none",n.href=o,n.download=t.filename,document.body.appendChild(n),n.click(),window.URL.revokeObjectURL(o)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",o)=>{const a=await fetch(`${n}app/GetAi2ChatReply?message=${t}&project=${e}${o?"&messageId="+o:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!a.ok)return void a.status;return(await a.json()).content.replace("@codicent-mini","").trim()};export{r as CodicentService};
2
2
  //# sourceMappingURL=codicent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codicent.js","sources":["../../../../src/services/codicent.ts"],"sourcesContent":[null],"names":["_a","baseUrl","token","initializeCodicent","window","Codicent","init","initialized","setInterval","clearInterval","initInterval","CodicentService","constructor","options","this","getAppTheme","datas","getDataMessages","tags","codicent","length","data","error","console","async","appButtons","BUTTON_TAG","map","d","sort","a","b","title","getAppTasks","getMessages","search","m","rows","MessageContent","content","split","prompt","slice","join","id","getAppPrompts","uploadFile","filename","formData","upload","getFileInfo","fileId","sendMessage","message","parentId","postMessage","type","chat","messageId","getChatReply3","getMessagesFast","publicCodicent","undefined","response","fetch","method","headers","getToken","body","JSON","status","Error","statusText","messages","json","forEach","createdAt","Date","parse","publicMessages","getPublicFlow","concat","getTime"],"mappings":"ycA4BA,IAAAA,MAGEC,0BACAC,EAAO,IACP,MAAAC,EAAW,SAAuB,IAARC,OAAAC,WAAaD,OAAAC,SAAAC,KAAA,CACvCJ,QAAkBD,aAA4B,OAM9CM,EAAaJ,IACd,IAAAI,EAAA,CAED,QAAuCC,aAAA,KACzBD,MACIA,GACHE,cAASC,EACd,GACE,KAEA,MAAAC,EACV,WAAAC,CAAiBC,GACEC,KAAAC,sBACR,IACZ,MAAAC,QAAAZ,OAAAC,SAAAY,gBAAA,CAAAC,KAAA,CAAA,aAAAC,SAAAL,KAAAK,kBAE2BH,EAAAI,OAAA,EAAAJ,EAAA,GAAAK,KAAA,KAId,MAAAC,GAgBZ,OAFEC,QAAAD,MAAA,4BAAAA,GAQA,IAES,sBAUkCE,gBAC3CC,SAD4DrB,OAAAC,SAAAY,gBAAA,CAAAC,KAAA,CAAAJ,KAAAD,QAAAa,YAAAP,SAAAL,KAAAK,YAC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,MAhCWA,EAAAO,OAgCX,IAAAC,MAAA,GAAAR,EAAAS,cAyBF,IAuBEC,QAAAV,EAAAW,OAyEM,GAvERD,EAeEE,SAAAvC,IAEKA,EAAAwC,UAA4B,IAAAC,KAAAA,KAyBjCC,MAAA1C,EAAAwC,WAAA,IA6BMf,EAAA,CAMwB,MAAAkB,QAAAjE,KAAAkE,cAAAnB,GAAUY,EAAMA,EAAAQ,OAAAF,GAAeN,EAAA5C,MAAA,CAAAC,EAAAC,IAAAA,EAAA6C,UAAAM,UAAApD,EAAA8C,UAAAM,WAC7D,CAES,OAAAT"}
1
+ {"version":3,"file":"codicent.js","sources":["../../../../src/services/codicent.ts"],"sourcesContent":[null],"names":["_a","baseUrl","token","initializeCodicent","window","Codicent","init","initialized","setInterval","clearInterval","initInterval","CodicentService","constructor","options","this","getAppTheme","datas","getDataMessages","tags","codicent","length","data","error","console","getAppButtons","async","appButtons","BUTTON_TAG","map","d","sort","a","b","title","getAppTasks","getMessages","search","m","rows","MessageContent","content","split","prompt","slice","join","id","getAppPrompts","uploadFile","filename","formData","upload","getFileInfo","fileId","sendMessage","message","parentId","postMessage","type","chat","messageId","getChatReply3","getMessagesFast","publicCodicent","undefined","response","fetch","method","headers","getToken","body","JSON","stringify","status","messages","json","forEach","createdAt","Date","parse","concat","publicMessages","getTime"],"mappings":"ycA4BA,IAAAA,MAGEC,0BACAC,EAAO,IACP,MAAAC,EAAW,SAAuB,IAARC,OAAAC,WAAaD,OAAAC,SAAAC,KAAA,CACvCJ,QAAkBD,aAA4B,OAM9CM,EAAaJ,IACd,IAAAI,EAAA,CAED,QAAuCC,aAAA,KACzBD,MACIA,GACHE,cAASC,EACd,GACE,KAEA,MAAAC,EACV,WAAAC,CAAiBC,GACEC,KAAAC,sBACR,IACI,MAAGC,QAAOZ,OAAAC,SAAAY,gBAAA,CAAAC,KAAA,CAAA,aAAAC,SAAAL,KAAAK,WAG3B,OAFCH,EAAAI,OAAA,EAAAJ,EAAA,GAAAK,KAA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,QAAAC,MAAA,GAA2BhE,sBAejE,CAEYiE,OAAA,OAEdC,QAAuC,CAiBvB,CAAA,0BAIdrD,KAAAsD,cAEM,CAAA,eAKN,oCAIFC,KAAAC,KAAgCC,UAAA,CAAQrD,OAAAC,SAetCL,KAAAK,SAAAiB,SAAAhB,aA0BF,IAAA4C,WAkBkBA,EAAAQ,oCA6DhB,IAAAC,QAAAT,EAAAU,OAmFK,GAjFPD,EAA4BE,SAAAtC,IA8D1BA,EAAAuC,UAAA,IAAAC,KAAAA,KAAAC,MAAAzC,EAAAuC,WAAA,IAmBKd,EAA4B,eA2BahD,mBAAiBgD,GA4BzDW,EAAAA,EAAAM,OAAAC,GAMwBP,EAAA3C,MAAA,CAAAC,EAAAC,IAAAA,EAAA4C,UAAAK,UAAAlD,EAAA6C,UAAAK,mBAA+BR,CAAA,EAGpD3D,KAAAqB,kBAOTjB,EAAAC,KACH,IAAAsD,EAAA"}
package/dist/index.d.ts CHANGED
@@ -36,6 +36,7 @@ interface CodicentServiceOptions {
36
36
  STRIPE_PUBLIC_KEY: string;
37
37
  SUBSCRIPTION_NEEDED: boolean;
38
38
  USER_PREFIX: string;
39
+ ANONYMOUS_TOKEN?: string;
39
40
  }
40
41
  declare class CodicentService {
41
42
  codicent: string;
@@ -66,6 +67,7 @@ declare class CodicentService {
66
67
  logout: () => void;
67
68
  isRegistered: () => boolean;
68
69
  getApps: () => Promise<AppInfo[] | null>;
70
+ addFollower: (nickname: string, followerNickname: string) => Promise<boolean>;
69
71
  cloneProject: (project: string, newProject: string) => Promise<boolean>;
70
72
  getNickname: () => Promise<string>;
71
73
  getChatInstructions: () => Promise<string>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codicent-app-sdk",
3
- "version": "0.3.34",
3
+ "version": "0.3.36",
4
4
  "description": "SDK for building AI-powered applications with Codicent",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",