codicent-app-sdk 0.3.84 → 0.3.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/MessageItem.d.ts.map +1 -1
- package/dist/cjs/components/MessageItem.js +1 -1
- package/dist/cjs/config/index.d.ts +5 -0
- package/dist/cjs/config/index.d.ts.map +1 -1
- package/dist/cjs/config/index.js +1 -1
- package/dist/cjs/hooks/useLocalization.d.ts +1 -0
- package/dist/cjs/hooks/useLocalization.d.ts.map +1 -1
- package/dist/cjs/hooks/useLocalization.js +1 -1
- package/dist/cjs/pages/FormAccept.d.ts.map +1 -1
- package/dist/cjs/pages/FormInvite.d.ts.map +1 -1
- package/dist/cjs/pages/FormInvite.js +1 -1
- package/dist/cjs/services/codicent.d.ts +1 -0
- package/dist/cjs/services/codicent.d.ts.map +1 -1
- package/dist/cjs/services/codicent.js +1 -1
- package/dist/esm/components/MessageItem.d.ts.map +1 -1
- package/dist/esm/components/MessageItem.js +1 -1
- package/dist/esm/config/index.d.ts +5 -0
- package/dist/esm/config/index.d.ts.map +1 -1
- package/dist/esm/config/index.js +1 -1
- package/dist/esm/hooks/useLocalization.d.ts +1 -0
- package/dist/esm/hooks/useLocalization.d.ts.map +1 -1
- package/dist/esm/hooks/useLocalization.js +1 -1
- package/dist/esm/pages/FormAccept.d.ts.map +1 -1
- package/dist/esm/pages/FormInvite.d.ts.map +1 -1
- package/dist/esm/pages/FormInvite.js +1 -1
- package/dist/esm/services/codicent.d.ts +1 -0
- package/dist/esm/services/codicent.d.ts.map +1 -1
- package/dist/esm/services/codicent.js +1 -1
- package/dist/index.d.ts +6 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItem.d.ts","sourceRoot":"","sources":["../../../src/components/MessageItem.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2H9C,QAAA,MAAM,WAAW,0HAad;IACD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,
|
|
1
|
+
{"version":3,"file":"MessageItem.d.ts","sourceRoot":"","sources":["../../../src/components/MessageItem.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2H9C,QAAA,MAAM,WAAW,0HAad;IACD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,4CA+QA,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("react-router-dom"),i=require("../services/codicent.js"),o=require("./Markdown.js");require("./Textarea.js"),require("./Button.js");var n=require("./Text.js");require("./Spinner.js"),require("./TextHeader.js"),require("./TypingIndicator.js"),require("./Dialog.js"),require("./ChatInput.js"),require("./CombinedPlaceholderDialog.js"),require("./ChatMessage.js"),require("./Header.js");var s=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("../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"),require("../stores/chatStore.js");var l=require("../hooks/useLocalization.js");require("../hooks/useAppStyles.js");var u=require("./FileThumbnail.js");require("./MessageInput.js"),require("./UploadFile.js"),require("./SnapFooter.js"),require("./Profile.js"),require("./Content.js"),require("./AiInput.js"),require("./SearchBox.js"),require("./HtmlView.js"),require("./Footer.js"),require("./Page.js");var d=require("../node_modules/@griffel/react/makeStyles.esm.js"),c=require("../node_modules/@fluentui/react-card/lib/components/Card/Card.js"),m=require("../node_modules/@fluentui/react-switch/lib/components/Switch/Switch.js"),g=require("../node_modules/@fluentui/react-icons/lib/icons/chunk-2.js"),p=require("../node_modules/@fluentui/react-icons/lib/icons/chunk-0.js"),h=require("../node_modules/@fluentui/react-card/lib/components/CardHeader/CardHeader.js"),j=require("../node_modules/@fluentui/react-skeleton/lib/components/Skeleton/Skeleton.js"),f=require("../node_modules/@fluentui/react-skeleton/lib/components/SkeletonItem/SkeletonItem.js"),x=require("../node_modules/@fluentui/react-text/lib/components/presets/Caption1/Caption1.js"),S=require("../node_modules/@fluentui/tokens/lib/tokens.js"),b=require("../node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-7.js");const q=d.makeStyles({iframe:{border:"none",width:"100%",height:"100%"},main:{gap:"36px",display:"flex",flexDirection:"column",flexWrap:"wrap"},card:{minWidth:"300px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",maxHeight:"11em",borderRadius:"10px",position:"relative"},expandedCard:{minWidth:"320px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",borderRadius:"10px",position:"relative"},text:{margin:"0.5em",whiteSpace:"normal",fontSize:"larger"},caption:{color:S.tokens.colorNeutralForeground3},headerImage:{borderRadius:"4px",maxWidth:"44px",maxHeight:"44px"},rectangle:{margin:0,top:"-5px",left:"-2px",width:"5px",position:"absolute",height:"100%"},fileList:{display:"flex",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin",msOverflowStyle:"none",padding:"4px",margin:"0 -4px",maxWidth:"100%",boxSizing:"border-box","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:S.tokens.colorNeutralStroke1,borderRadius:"3px"}},htmlButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},headerButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},iconButtonRow:{position:"absolute",top:"0.5em",right:"0.5em",display:"flex",alignItems:"center",gap:"0.5em",zIndex:2},content:{overflow:"hidden",transition:"max-height 0.3s ease-out",userSelect:"text"},truncated:{maxHeight:"10em"},header:{display:"flex",flexDirection:"row",gap:"0.5em",alignItems:"center"},todoSwitch:{transform:"scale(0.8)","& .fui-Switch__label":{fontSize:"0.75rem"}}});exports.default=({header:d,description:S,timestamp:k,text:w,image:C,tags:I,id:_,fileIds:v,codicentService:O,busy:E,onEdit:N,onShowHtmlPreview:T})=>{const y=q(),A=r.useNavigate(),[R,F]=t.useState(!1),[B,L]=t.useState(!1),[H,P]=t.useState("unknown"),[D,G]=t.useState(!1),z=t.useRef(null),M=Object.keys(a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")),V=M.find((e=>I.includes(e)))||(v.length>0?M.find((e=>"file"===e)):void 0),[K,W]=t.useState([]),$=I.includes("todo"),{t:U}=l.default(),Y=["TYPE","CUSTOMER","CONTACT","SALESPERSON","MESSAGE","COMPANY","PHONE","EMAIL","WEBSITE","INFO","FÖRETAG","ROLE","KONTAKT"],X=[U("Typ"),U("Kund"),U("Kontakt"),U("Säljare"),U("Meddelande"),U("Företag"),U("Telefon"),U("E-post"),U("Hemsida"),U("Info"),U("Företag"),U("Roll"),U("Kontakt")];t.useEffect((()=>{Promise.all(v.map((e=>O.getFileInfo(e)))).then((e=>{W(e)}))}),[O,W,v]),t.useEffect((()=>{const e=()=>{if(z.current){const e=z.current.scrollHeight>100+(K.length>0?-72:0);L(e)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[w,K]),t.useEffect((()=>{if($){(async()=>{try{const e=await O.getTodoStatus(_);P(e)}catch(e){console.error("Error loading todo status:",e),P("unknown")}})()}}),[$,_,O]);const J=()=>F(!R),Q=I.includes("chat")&&(w.includes("#function_result")||w.includes("#finish_reason_function_call")),Z=e=>{const t=e.indexOf("```html");if(-1===t)return e;const r=e.indexOf("```",t+7);if(-1===r)return e.substring(t+7);return e.substring(t+7,r)},ee=new s.default(w).data,te=V&&a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].editable,re=V&&a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].imageSize||void 0;return e.jsxs(c.Card,{className:R?y.expandedCard:y.card,style:{backgroundColor:a.getConfigValue("MESSAGE_HIDE_BAR")?V?a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].color:a.getConfigValue("APP_HEADER_COLOR")||"#eee":"#eee"},onClick:I.includes("chat")?e=>{I.includes("chat")&&(e&&e.stopPropagation(),A("/chat?id="+_))}:void 0,children:[!a.getConfigValue("MESSAGE_HIDE_BAR")&&e.jsx("div",{className:y.rectangle,style:{backgroundColor:V?a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].color:a.getConfigValue("APP_HEADER_COLOR")||void 0}}),e.jsxs("div",{className:y.iconButtonRow,children:[$&&e.jsx(m.Switch,{className:y.todoSwitch,checked:"done"===H,onChange:(e,t)=>(async e=>{if(!D){G(!0);try{const t=e?"done":"undone";await O.updateTodoStatus(_,t)&&P(t)}catch(e){console.error("Error updating todo status:",e)}finally{G(!1)}}})(t.checked),disabled:D||"unknown"===H,label:U("done"===H?"Done":"Todo")}),te&&N&&e.jsx(b.Edit20Regular,{className:y.htmlButton,onClick:()=>N()}),T&&!te&&I.includes("html")&&e.jsx(g.FullScreenMaximizeRegular,{className:y.htmlButton,onClick:e=>{e.stopPropagation(),T(Z(w))}}),B&&!I.includes("chat")&&R&&e.jsx(p.ArrowCollapseAllRegular,{className:y.headerButton,onClick:J}),B&&!I.includes("chat")&&!R&&e.jsx(p.ArrowExpandAllRegular,{className:y.headerButton,onClick:J})]}),e.jsx(h.CardHeader,{image:C?e.jsx("img",{className:y.headerImage,src:"app_logo.svg",alt:"User"}):null,header:E?e.jsx(j.Skeleton,{style:{width:"50%"},children:e.jsx(f.SkeletonItem,{})}):e.jsxs("div",{className:y.header,children:[e.jsx(n.Text,{weight:"semibold",children:d}),k&&e.jsx(n.Text,{weight:"regular",children:k})]}),description:e.jsx(x.Caption1,{className:y.caption,children:S})}),e.jsxs("div",{ref:z,className:`${y.content} ${R?"":y.truncated}`,children:[K.length>0&&e.jsx("div",{className:y.fileList,children:K.map((t=>e.jsx(u.FileThumbnail,{file:t,thumbnailSize:re,getImageUrl:i.CodicentService.getImageUrl,onClick:()=>{t.contentType.startsWith("image")?A(`/image?id=${_}&file=${t.id}`):i.CodicentService.downloadFile(t)}},t.id)))}),E?e.jsxs(j.Skeleton,{style:{width:"100%"},children:[e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{})]}):e.jsx("div",{className:y.text,children:I.includes("html")?e.jsx("iframe",{className:y.iframe,title:"html",srcDoc:Z(w),sandbox:"allow-same-origin allow-scripts"}):I.includes("crm")&&0===Object.keys(ee).length?e.jsx(o.default,{content:Q?"*Tänker...*":ee?(()=>{const e=new RegExp(`(${Y.join("|")})\\s*:\\s*`,"gi"),t=w.replace(e,((e,t)=>{const r=Y.indexOf(t.toUpperCase());-1===r&&console.log("Field not found:",t);return`\n**${-1!==r?X[r]:t}:** `}));return t.trim()})():w}):e.jsx(o.default,{content:Q?"*Tänker...*":ee&&ee&&Object.keys(ee).length>0?Object.keys(ee).map((e=>{const t=Y.indexOf(e.toUpperCase());return`**${-1!==t?X[t]:e}:** ${ee[e]}\n`})).join("\n"):w})})]})]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("react-router-dom"),i=require("../services/codicent.js"),o=require("./Markdown.js");require("./Textarea.js"),require("./Button.js");var n=require("./Text.js");require("./Spinner.js"),require("./TextHeader.js"),require("./TypingIndicator.js"),require("./Dialog.js"),require("./ChatInput.js"),require("./CombinedPlaceholderDialog.js"),require("./ChatMessage.js"),require("./Header.js");var s=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("../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"),require("../stores/chatStore.js");var l=require("../hooks/useLocalization.js");require("../hooks/useAppStyles.js");var u=require("./FileThumbnail.js");require("./MessageInput.js"),require("./UploadFile.js"),require("./SnapFooter.js"),require("./Profile.js"),require("./Content.js"),require("./AiInput.js"),require("./SearchBox.js"),require("./HtmlView.js"),require("./Footer.js"),require("./Page.js");var d=require("../node_modules/@griffel/react/makeStyles.esm.js"),c=require("../node_modules/@fluentui/react-card/lib/components/Card/Card.js"),m=require("../node_modules/@fluentui/react-switch/lib/components/Switch/Switch.js"),g=require("../node_modules/@fluentui/react-icons/lib/icons/chunk-2.js"),p=require("../node_modules/@fluentui/react-icons/lib/icons/chunk-0.js"),h=require("../node_modules/@fluentui/react-card/lib/components/CardHeader/CardHeader.js"),j=require("../node_modules/@fluentui/react-skeleton/lib/components/Skeleton/Skeleton.js"),f=require("../node_modules/@fluentui/react-skeleton/lib/components/SkeletonItem/SkeletonItem.js"),x=require("../node_modules/@fluentui/react-text/lib/components/presets/Caption1/Caption1.js"),S=require("../node_modules/@fluentui/tokens/lib/tokens.js"),b=require("../node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-7.js");const q=d.makeStyles({iframe:{border:"none",width:"100%",height:"100%"},main:{gap:"36px",display:"flex",flexDirection:"column",flexWrap:"wrap"},card:{minWidth:"300px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",maxHeight:"11em",borderRadius:"10px",position:"relative"},expandedCard:{minWidth:"320px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",borderRadius:"10px",position:"relative"},text:{margin:"0.5em",whiteSpace:"normal",fontSize:"larger"},caption:{color:S.tokens.colorNeutralForeground3},headerImage:{borderRadius:"4px",maxWidth:"44px",maxHeight:"44px"},rectangle:{margin:0,top:"-5px",left:"-2px",width:"5px",position:"absolute",height:"100%"},fileList:{display:"flex",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin",msOverflowStyle:"none",padding:"4px",margin:"0 -4px",maxWidth:"100%",boxSizing:"border-box","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:S.tokens.colorNeutralStroke1,borderRadius:"3px"}},htmlButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},headerButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},iconButtonRow:{position:"absolute",top:"0.5em",right:"0.5em",display:"flex",alignItems:"center",gap:"0.5em",zIndex:2},content:{overflow:"hidden",transition:"max-height 0.3s ease-out",userSelect:"text"},truncated:{maxHeight:"10em"},header:{display:"flex",flexDirection:"row",gap:"0.5em",alignItems:"center"},todoSwitch:{transform:"scale(0.8)","& .fui-Switch__label":{fontSize:"0.75rem"}}});exports.default=({header:d,description:S,timestamp:k,text:w,image:C,tags:I,id:_,fileIds:v,codicentService:O,busy:E,onEdit:N,onShowHtmlPreview:T})=>{const y=q(),A=r.useNavigate(),[R,F]=t.useState(!1),[B,L]=t.useState(!1),[H,P]=t.useState("unknown"),[D,G]=t.useState(!1),z=t.useRef(null),M=Object.keys(a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")),V=M.find((e=>I.includes(e)))||(v.length>0?M.find((e=>"file"===e)):void 0),[K,W]=t.useState([]),$=I.includes("todo"),{t:U}=l.default(),Y=["TYPE","CUSTOMER","CONTACT","SALESPERSON","MESSAGE","COMPANY","PHONE","EMAIL","WEBSITE","INFO","FÖRETAG","ROLE","KONTAKT"],X=[U("Typ"),U("Kund"),U("Kontakt"),U("Säljare"),U("Meddelande"),U("Företag"),U("Telefon"),U("E-post"),U("Hemsida"),U("Info"),U("Företag"),U("Roll"),U("Kontakt")];t.useEffect((()=>{Promise.all(v.map((e=>O.getFileInfo(e)))).then((e=>{W(e)}))}),[O,W,v]),t.useEffect((()=>{const e=()=>{if(z.current){const e=z.current.scrollHeight>100+(K.length>0?-72:0);L(e)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[w,K]),t.useEffect((()=>{if($){(async()=>{try{const e=await O.getTodoStatus(_);P(e)}catch(e){console.error("Error loading todo status:",e),P("unknown")}})()}}),[$,_,O]);const J=()=>F(!R),Q=I.includes("chat")&&(w.includes("#function_result")||w.includes("#finish_reason_function_call")),Z=e=>{const t=e.indexOf("```html");if(-1===t)return e;const r=e.indexOf("```",t+7);if(-1===r)return e.substring(t+7);return e.substring(t+7,r)},ee=new s.default(w).data,te=V&&a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].editable,re=V&&a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].imageSize||void 0;return e.jsxs(c.Card,{className:R?y.expandedCard:y.card,style:{backgroundColor:a.getConfigValue("MESSAGE_HIDE_BAR")?V?a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].color:a.getConfigValue("APP_HEADER_COLOR")||"#eee":"#eee"},onClick:I.includes("chat")?e=>{I.includes("chat")&&(e&&e.stopPropagation(),A("/chat?id="+_))}:void 0,children:[!a.getConfigValue("MESSAGE_HIDE_BAR")&&e.jsx("div",{className:y.rectangle,style:{backgroundColor:V?a.getConfigValue("LOGBOOK_TAG_DEFINITIONS")[V].color:a.getConfigValue("APP_HEADER_COLOR")||void 0}}),e.jsxs("div",{className:y.iconButtonRow,children:[$&&e.jsx(m.Switch,{className:y.todoSwitch,checked:"done"===H,onChange:(e,t)=>(async e=>{if(!D){G(!0);try{const t=e?"done":"undone";await O.updateTodoStatus(_,t)&&P(t)}catch(e){console.error("Error updating todo status:",e)}finally{G(!1)}}})(t.checked),disabled:D||"unknown"===H,label:U("done"===H?"Done":"Todo")}),te&&N&&e.jsx(b.Edit20Regular,{className:y.htmlButton,onClick:()=>N()}),T&&!te&&I.includes("html")&&e.jsx(g.FullScreenMaximizeRegular,{className:y.htmlButton,onClick:e=>{e.stopPropagation(),T(Z(w))}}),B&&!I.includes("chat")&&R&&e.jsx(p.ArrowCollapseAllRegular,{className:y.headerButton,onClick:J}),B&&!I.includes("chat")&&!R&&e.jsx(p.ArrowExpandAllRegular,{className:y.headerButton,onClick:J})]}),e.jsx(h.CardHeader,{image:C?e.jsx("img",{className:y.headerImage,src:"app_logo.svg",alt:"User"}):null,header:E?e.jsx(j.Skeleton,{style:{width:"50%"},children:e.jsx(f.SkeletonItem,{})}):e.jsxs("div",{className:y.header,children:[e.jsx(n.Text,{weight:"semibold",children:d}),k&&e.jsx(n.Text,{weight:"regular",children:k})]}),description:e.jsx(x.Caption1,{className:y.caption,children:S})}),e.jsxs("div",{ref:z,className:`${y.content} ${R?"":y.truncated}`,children:[K.length>0&&e.jsx("div",{className:y.fileList,children:K.map((t=>e.jsx(u.FileThumbnail,{file:t,thumbnailSize:re,getImageUrl:i.CodicentService.getImageUrl,onClick:()=>{t.contentType.startsWith("image")?A(`/image?id=${_}&file=${t.id}`):i.CodicentService.downloadFile(t)}},t.id)))}),E?e.jsxs(j.Skeleton,{style:{width:"100%"},children:[e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{}),e.jsx(f.SkeletonItem,{})]}):e.jsx("div",{className:y.text,children:I.includes("html")?e.jsx("iframe",{className:y.iframe,title:"html",srcDoc:Z(w),sandbox:"allow-same-origin allow-scripts"}):I.includes("crm")&&0===Object.keys(ee).length?e.jsx(o.default,{content:Q?"*"+U("Tänker")+"...*":ee?(()=>{const e=new RegExp(`(${Y.join("|")})\\s*:\\s*`,"gi"),t=w.replace(e,((e,t)=>{const r=Y.indexOf(t.toUpperCase());-1===r&&console.log("Field not found:",t);return`\n**${-1!==r?X[r]:t}:** `}));return t.trim()})():w}):e.jsx(o.default,{content:Q?"*"+U("Tänker")+"...*":ee&&ee&&Object.keys(ee).length>0?Object.keys(ee).map((e=>{const t=Y.indexOf(e.toUpperCase());return`**${-1!==t?X[t]:e}:** ${ee[e]}\n`})).join("\n"):w})})]})]})};
|
|
@@ -114,6 +114,11 @@ export interface AppConfigOptions {
|
|
|
114
114
|
FORM_BACKGROUND_IMAGE_URL: undefined | string;
|
|
115
115
|
AUTO_TRANSLATE: boolean;
|
|
116
116
|
FORCE_LANGUAGE: string | undefined;
|
|
117
|
+
TRANSLATIONS: {
|
|
118
|
+
[key: string]: {
|
|
119
|
+
[key: string]: string;
|
|
120
|
+
};
|
|
121
|
+
} | undefined;
|
|
117
122
|
APP_LOGBOOK_TITLE: undefined | string;
|
|
118
123
|
LOGIN_WELCOME_TEXT: string | undefined;
|
|
119
124
|
LOGIN_HIDE_WELCOME: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;;IAKpB,iBAAiB,EAAE,MAAM,CAAM;IAC/B,2BAA2B,EAAE,MAAM,CAAM;IACzC,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,OAAO,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,GAAG,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YAC1C,KAAK,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YACxD,iBAAiB,EAAE,MAAM,CAAC;YAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;YACvB,gBAAgB,EAAE,MAAM,CAAC;YACzB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACtB,CAAC;KACH,CAAC;CAyBH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,yBAAyB,EAAE,SAAS,GAAG,MAAM,CAAC;IAC9C,cAAc,EAAE,SAAS,GAAG,MAAM,CAAC;IACnC,UAAU,EAAE,SAAS,CAAC;IACtB,gBAAgB,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,yBAAyB,EAAE,SAAS,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,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,yBAAyB,EAAE,OAAO,CAAC;IACnC,oBAAoB,EAAE,SAAS,GAAG,MAAM,CAAC;IACzC,2BAA2B,EAAE,OAAO,CAAC;CACtC;AAuHD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAG5F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,QAgBtE"}
|
package/dist/cjs/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=require("../node_modules/mermaid/dist/mermaid.core.js");class
|
|
1
|
+
"use strict";var _=require("../node_modules/mermaid/dist/mermaid.core.js");class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_API_KEY:"",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIP_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0,FORCE_LANGUAGE:void 0,TRANSLATIONS:void 0,LOGIN_WELCOME_TEXT:void 0,LOGIN_HIDE_WELCOME:!1,LOGIN_LOGO_URL:void 0,HIDE_CHAT_ADD_FILE_BUTTON:!1,FORM_ACCEPT_MARKDOWN:void 0,RESTART_AUDIO_ON_TAKE_PHOTO:!1};const E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);exports.AppConfig=T,exports.getConfigValue=function(_){return E[_]},exports.initCodicentApp=function(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);void 0!==T.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0),_.default.initialize({startOnLoad:!1})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalization.d.ts","sourceRoot":"","sources":["../../../src/hooks/useLocalization.ts"],"names":[],"mappings":"AAOA,UAAU,cAAc;IACtB,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"useLocalization.d.ts","sourceRoot":"","sources":["../../../src/hooks/useLocalization.ts"],"names":[],"mappings":"AAOA,UAAU,cAAc;IACtB,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAgGD,eAAO,MAAM,gBAAgB,YAAiB,CAAC;AAE/C,QAAA,MAAM,eAAe;aAuCX,MAAM;;+BAlByB,MAAM;;;CAmF9C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../node_modules/i18next/dist/esm/i18next.js"),n=require("../services/codicent.js"),a=require("../config/index.js"),r=require("../node_modules/react-i18next/dist/es/initReactI18next.js"),s=require("../node_modules/react-i18next/dist/es/useTranslation.js");const i=()=>{const e=a.getConfigValue("FORCE_LANGUAGE");if(e)return{source:"force_config",language:e};if("undefined"!=typeof window){const e=new URLSearchParams(window.location.search),t=e.get("lang")||e.get("language");if(t)return{source:"url_param",language:t}}if("undefined"!=typeof navigator&&navigator.language){return{source:"browser",language:navigator.language.split("-")[0]}}return{source:"default",language:a.getConfigValue("DEFAULT_LANGUAGE")||"sv"}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../node_modules/i18next/dist/esm/i18next.js"),n=require("../services/codicent.js"),a=require("../config/index.js"),r=require("../node_modules/react-i18next/dist/es/initReactI18next.js"),s=require("../node_modules/react-i18next/dist/es/useTranslation.js");const i=()=>{const e=a.getConfigValue("FORCE_LANGUAGE");if(e)return{source:"force_config",language:e};if("undefined"!=typeof window){const e=new URLSearchParams(window.location.search),t=e.get("lang")||e.get("language");if(t)return{source:"url_param",language:t}}if("undefined"!=typeof navigator&&navigator.language){return{source:"browser",language:navigator.language.split("-")[0]}}return{source:"default",language:a.getConfigValue("DEFAULT_LANGUAGE")||"sv"}};let o=null;const l=()=>{if(null===o){const{language:e}=i();o=e}return o},u=()=>{const e=a.getConfigValue("TRANSLATIONS");if(e){const t={};for(const[n,a]of Object.entries(e))t[n]={translation:a};return t}return{en:{translation:{Hello:"Hello"}},sv:{translation:{Hello:"Hej"}}}},c=()=>{if(t.default.isInitialized){const e=u();Object.keys(e).forEach((n=>{t.default.addResourceBundle(n,"translation",e[n].translation,!0,!0)}))}else t.default.use(r.initReactI18next).init({resources:u(),lng:l(),fallbackLng:a.getConfigValue("DEFAULT_LANGUAGE")||"sv",interpolation:{escapeValue:!1}})};c();exports.default=()=>{const{t:t,i18n:r}=s.useTranslation(),[o,u]=e.useState((()=>l())),[g,d]=e.useState(JSON.parse(localStorage.getItem("app-translations")||"{}")),f=e.useRef([]);e.useEffect((()=>{globalThis.__CODICENT_REINIT_I18N__&&(c(),globalThis.__CODICENT_REINIT_I18N__=!1)}),[]),e.useEffect((()=>{r.changeLanguage(o)}),[o,r]);const _=e.useCallback((e=>{const{source:t}=i();"force_config"!==t?"url_param"!==t?u(e):console.warn("Language setting ignored due to URL parameter"):console.warn("Language setting ignored due to FORCE_LANGUAGE configuration")}),[]),m=e.useCallback((()=>i()),[]);return{t:e.useCallback((e=>(r.exists(e)||(async(e,t)=>{const r=`${t} - ${e}`;let s=g[t]?.[e]||void 0;return a.getConfigValue("AUTO_TRANSLATE")&&!s&&-1===f.current.indexOf(r)&&(f.current=[...f.current,r],localStorage.setItem("app-translations",JSON.stringify(g)),s=await n.CodicentService.getMiniChatReply(`Översätt '${e}' till språk '${t}' och svara endast med översättningen.`),s&&s.includes("Error code:")&&(s=void 0),s&&(!e.trim().startsWith('"')&&s.trim().startsWith('"')&&s.trim().endsWith('"')&&(s=s.trim().slice(1,-1)),!e.trim().startsWith("'")&&s.trim().startsWith("'")&&s.trim().endsWith("'")&&(s=s.trim().slice(1,-1)),g[t]={...g[t],[e]:s},localStorage.setItem("app-translations",JSON.stringify(g)),d(g))),s||e})(e,o).then((t=>{r.addResource(o,"translation",e,t)})),t(e))),[r,t,g,o]),currentLanguage:o,setCurrentLanguage:_,getLanguageInfo:m,isForced:["force_config","url_param"].includes(i().source)}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAccept.d.ts","sourceRoot":"","sources":["../../../src/pages/FormAccept.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormAccept.d.ts","sourceRoot":"","sources":["../../../src/pages/FormAccept.tsx"],"names":[],"mappings":"AAiCA,QAAA,MAAM,UAAU,+CAkDf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormInvite.d.ts","sourceRoot":"","sources":["../../../src/pages/FormInvite.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,OAAO,EAAE,gBAAgB,EAA6C,MAAM,UAAU,CAAC;AAsCvF,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"FormInvite.d.ts","sourceRoot":"","sources":["../../../src/pages/FormInvite.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,OAAO,EAAE,gBAAgB,EAA6C,MAAM,UAAU,CAAC;AAsCvF,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CA+I/C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react");require("../components/Markdown.js"),require("../components/Textarea.js");var n=require("../components/Button.js"),o=require("../components/Title.js");require("../components/Spinner.js");var t=require("../components/Label.js"),i=require("../components/Input.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 a=require("../hooks/useStateWithLocalStorage.js");require("../services/codicent.js"),require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var s=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");var l=require("../utils/helpers.js");require("./AppFrame.js"),require("./Snap.js"),require("./Search.js"),require("./Login.js"),require("./CrmPage.js"),require("./ImageView.js"),require("./FormAccept.js"),require("./Sales.js"),require("../stores/chatStore.js");var u=require("../hooks/useLocalization.js");require("../hooks/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");var c=require("../components/Content.js");require("../components/AiInput.js"),require("../components/SearchBox.js"),require("../components/HtmlView.js"),require("../components/Footer.js");var d=require("../components/Page.js"),p=require("../node_modules/@griffel/react/makeStyles.esm.js"),m=require("../node_modules/@fluentui/react-utilities/lib/hooks/useId.js"),j=require("../node_modules/@fluentui/react-combobox/lib/components/Dropdown/Dropdown.js"),h=require("../node_modules/@fluentui/react-combobox/lib/components/Option/Option.js");const k=p.makeStyles({inputAndButton:{display:"flex",gap:"10px"},input:{minWidth:"90%"},container:{maxWidth:"640px",margin:"0 auto",backgroundPosition:"calc(50% + 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"100%"},generatedLinkTitle:{marginBottom:"0.5em",fontWeight:"bold"},orderedList:{marginLeft:"20px",marginBottom:"1em"},instructionParagraph:{marginBottom:"1em",fontWeight:"bold"}});exports.default=({state:p})=>{const q=k(),{service:g}=p,{t:x}=u.default(),[v,f]=a.default(p.context.selectedApp+"_forms",[]),[b,w]=r.useState(),[S,y]=r.useState(),[_,C]=r.useState(!1),[$,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react");require("../components/Markdown.js"),require("../components/Textarea.js");var n=require("../components/Button.js"),o=require("../components/Title.js");require("../components/Spinner.js");var t=require("../components/Label.js"),i=require("../components/Input.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 a=require("../hooks/useStateWithLocalStorage.js");require("../services/codicent.js"),require("../utils/MessageContent.js"),require("../node_modules/tinycolor2/esm/tinycolor.js"),require("../_virtual/index.js");var s=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");var l=require("../utils/helpers.js");require("./AppFrame.js"),require("./Snap.js"),require("./Search.js"),require("./Login.js"),require("./CrmPage.js"),require("./ImageView.js"),require("./FormAccept.js"),require("./Sales.js"),require("../stores/chatStore.js");var u=require("../hooks/useLocalization.js");require("../hooks/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");var c=require("../components/Content.js");require("../components/AiInput.js"),require("../components/SearchBox.js"),require("../components/HtmlView.js"),require("../components/Footer.js");var d=require("../components/Page.js"),p=require("../node_modules/@griffel/react/makeStyles.esm.js"),m=require("../node_modules/@fluentui/react-utilities/lib/hooks/useId.js"),j=require("../node_modules/@fluentui/react-combobox/lib/components/Dropdown/Dropdown.js"),h=require("../node_modules/@fluentui/react-combobox/lib/components/Option/Option.js");const k=p.makeStyles({inputAndButton:{display:"flex",gap:"10px"},input:{minWidth:"90%"},container:{maxWidth:"640px",margin:"0 auto",backgroundPosition:"calc(50% + 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"100%"},generatedLinkTitle:{marginBottom:"0.5em",fontWeight:"bold"},orderedList:{marginLeft:"20px",marginBottom:"1em"},instructionParagraph:{marginBottom:"1em",fontWeight:"bold"}});exports.default=({state:p})=>{const q=k(),{service:g}=p,{t:x}=u.default(),[v,f]=a.default(p.context.selectedApp+"_forms",[]),[b,w]=r.useState(),[S,y]=r.useState(),[_,C]=r.useState(!1),[$,T]=r.useState(),I=m.useId("form-dropdown");r.useEffect((()=>{g.getForms().then((e=>{e.sort(((e,r)=>e.name.localeCompare(r.name))),f(e)}))}),[g,x,f]);const L=void 0!==navigator.share;return e.jsx(d.Page,{children:e.jsx("div",{className:q.container,style:{backgroundImage:`url(${s.getConfigValue("COMPOSE_BACKGROUND_IMAGE_URL")})`},children:e.jsxs(c.default,{children:[e.jsx(o.Title,{children:x("Skapa länk till formulär")}),e.jsx("p",{className:q.instructionParagraph,children:x("Instruktioner")}),e.jsxs("ol",{className:q.orderedList,children:[e.jsx("li",{children:x("Välj ett formulär från rullgardinsmenyn nedan. Detta formulär kommer att användas för den genererade länken.")}),e.jsx("li",{children:x("Klicka på 'Skapa länk' för att generera en unik länk. Länken visar var aktiv och kan användas för att svara på formuläret.")}),e.jsx("li",{children:x("När länken visas, kan du klicka på kopiera-ikonen för att kopiera länken till ditt urklipp.")}),e.jsx("li",{children:x("Om din enhet stödjer det, kan du även använda dela-knappen för att dela länken direkt.")}),e.jsx("li",{children:x("Kom ihåg att spara (skriva ner) koden")})]}),e.jsx("label",{id:I,className:q.instructionParagraph,children:x("Välj formulär")}),e.jsx(j.Dropdown,{"aria-labelledby":I,placeholder:"-",onOptionSelect:(e,r)=>T(r.optionValue),children:v.map((r=>e.jsxs(h.Option,{value:r.name,text:`${r.title} (${r.name})`,children:[`${r.title} (${r.name})`," "]},r.name)))}),e.jsx(n.Button,{appearance:"primary",disabled:!$,onClick:()=>{const e=v.find((e=>e.name===$));e?.url?g.sendMessage(`#ss-link #${$}`).then((r=>{const n=new Date(Date.now()+2592e5);g.generateApiToken(n).then((n=>{const o=e.url.includes("?")?"&":"?",t=`${e.url}${o}token=${n}`;w(t);const i=l.formatGuidToShorterReadableCode(r);y(i)}))})):g.sendMessage(`#ss-link #${$}`).then((e=>{const r=`${window.location.protocol}//${window.location.hostname}${window.location.port?":"+window.location.port:""}${window.location.pathname}`;w(`${r}#/formaccept?id=${e}`);const n=l.formatGuidToShorterReadableCode(e);y(n)}))},children:x("Skapa länk")}),b&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:q.generatedLinkTitle,children:x("Här är din genererade länk (du kan kopiera eller dela den):")}),e.jsx("div",{className:q.inputAndButton,children:e.jsx(i.Input,{className:q.input,value:b,readOnly:!0,onFocus:e=>e.target.select()})}),e.jsx("br",{}),e.jsxs("div",{className:q.inputAndButton,children:[e.jsx(n.Button,{appearance:"primary",title:x("Kopiera länk"),icon:"CopyRegular",onClick:()=>{b&&(navigator.clipboard.writeText(b),C(!0),setTimeout((()=>{C(!1),w(void 0)}),2e3))},children:x("Kopiera")}),L&&e.jsx(n.Button,{appearance:"primary",title:x("Dela länk"),icon:"ShareRegular",onClick:()=>{b&&(navigator.share({url:b}),setTimeout((()=>{w(void 0)}),2e3))},children:x("Dela")})]}),_&&e.jsx(t.Label,{children:x("Länk kopierad!")})]})]})})})};
|
|
@@ -61,6 +61,7 @@ export declare class CodicentService {
|
|
|
61
61
|
getFileInfo: (fileId: string) => Promise<FileInfo>;
|
|
62
62
|
static getImageUrl: (fileId: string, width: number) => string;
|
|
63
63
|
static getFileUrl: (fileId: string, extension?: string) => string;
|
|
64
|
+
generateApiToken: (expires?: Date, forUserNickname?: string) => Promise<string>;
|
|
64
65
|
sendMessage: (message: string, parentId?: string) => Promise<string>;
|
|
65
66
|
chat: (message: string, messageId?: string) => Promise<ChatMessageReply>;
|
|
66
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AAkCA,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,MA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F,cAAc,aA/EiB,MAAM,wCA+EH;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,CAoB9D;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,+BAqCP;IAEF,YAAY,+BAeV;IAEF,MAAM,CAAC,YAAY,SAAgB,QAAQ,mBAyBzC;IAEF,MAAM,CAAC,gBAAgB,YAAmB,MAAM,YAAW,MAAM,cAAgC,MAAM,iCA0BrG;IAEF,QAAQ,QAAa,OAAO,CAAC,IAAI,EAAE,CAAC,CAMlC;IAEF,WAAW,OAAc,MAAM,kBAO7B;IAGF,OAAO,CAAC,kBAAkB;IAM1B,aAAa,cAAqB,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAiB/E;IAEF,gBAAgB,cAAqB,MAAM,UAAU,MAAM,GAAG,QAAQ,sBAcpE;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),a=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/",n="-";const i=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:n,baseUrl:o}),!0);let s=i();if(!s){const t=setInterval((()=>{s=i(),s&&clearInterval(t)}),100)}class r{constructor(t){this.createDataMessage=async(t,e)=>await window.Codicent.data.create({codicent:this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e)=>await window.Codicent.data.read({codicent:this.codicent,tag:t,search:e}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e)=>await window.Codicent.data.update({id:t,data:e,codicent:this.codicent}),this.deleteDataMessage=async t=>await window.Codicent.data.delete({id:t,codicent:this.codicent}),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 a.default(t.content).content.split("\n"),o=e[0],n=e.slice(1).join("\n");return{id:t.id,title:o,content:n}})),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,a=100,n=void 0)=>{const i=await this.request(`${o}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:a})});let s=await i.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n){const t=await this.getPublicFlow(n);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let a=[];const o=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:10});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(o)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,a)=>e===a.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,a,n)=>{const i=await fetch(`${o}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:a})});if(!i.ok)return"";const s=await i.text();return window.Codicent.init({token:n,baseUrl:o}),s},this.loginUser=async(t,e)=>{try{const a=await fetch(`${o}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!a.ok)return 404===a.status||400===a.status?null:401===a.status?(this.handleUnauthorized(),null):"";const n=await a.text();return this.setToken(n),n}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,a)=>e===a.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 a=await fetch(`${o}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText||"Failed to add follower!"}`);return await a.json()},this.cloneProject=async(t,e)=>{const a=await fetch(`${o}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText}`);let n=await a.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),a=JSON.parse(e),i=a.sub||a.userId,s=await fetch(`${o}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?(this.handleUnauthorized(),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}),a=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==a&&(console.log("updating instructions",a),await window.Codicent.postMessage({message:a,type:"text",parentId:e[0].id})):(console.log("new instructions",a),await window.Codicent.postMessage({message:a,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const a=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(!a.ok)throw 401===a.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${a.statusText}`);const n=await a.json(),{email:i,picture:s,description:r,followers:c,properties:h,owner:d}=n;return{nickname:t,email:i,name:r,picture:s,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:a,picture:n})=>{const i=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:a,picture:n,description:""})});if(!i.ok)throw i.status,new Error(`${i.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const a=await fetch(`${o}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`requestInvite() => ${a.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const a=await fetch(`${o}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`updateMembersAccess() => ${a.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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:o})},this.getToken=()=>n,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:a}=await e.json();return a},this.redirectToCheckout=async t=>{const a=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!a)throw new Error("Stripe failed to load");const o=await this.createCheckoutSession(t),{error:n}=await a.redirectToCheckout({sessionId:o});if(n)throw new Error(n.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 a=await e.json();return a=a.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),a},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 a=await e.json();return a.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a},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 a={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},n=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(a)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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],a=atob(t),o=JSON.parse(a).nickname;if(!await this.addFollower(e,o))throw new Error("Failed to add follower: "+o)}catch(t){console.error("Error extracting adding anonymous follower:",t)}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 this.request(`${o}app/GetForms?codicent=${this.codicent}`,"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.getTodoStatus=async t=>{const e=await fetch(`${o}/app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const a=await fetch(`${o}/app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)return console.warn(`updateTodoStatus() => ${a.statusText}`),!1;return await a.json()},this.codicent="",this.options=t}async request(t,e,a={}){const o={};a.headers&&a.headers.forEach((([t,e])=>{o[t]=e}));const n=await fetch(t,{...a,method:e,headers:o});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}}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 a=window.URL.createObjectURL(t),o=document.createElement("a");o.style.display="none",o.href=a,o.download=e.filename,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(a)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",a)=>{const n=await fetch(`${o}app/GetAi2ChatReply?message=${t}&project=${e}${a?"&messageId="+a:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!n.ok)return void n.status;return(await n.json()).content.replace("@codicent-mini","").trim()},exports.CodicentService=r;
|
|
1
|
+
"use strict";var t,e=require("../node_modules/@stripe/stripe-js/dist/index.js"),a=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/",n="-";const i=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:n,baseUrl:o}),!0);let s=i();if(!s){const t=setInterval((()=>{s=i(),s&&clearInterval(t)}),100)}class r{constructor(t){this.createDataMessage=async(t,e)=>await window.Codicent.data.create({codicent:this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e)=>await window.Codicent.data.read({codicent:this.codicent,tag:t,search:e}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e)=>await window.Codicent.data.update({id:t,data:e,codicent:this.codicent}),this.deleteDataMessage=async t=>await window.Codicent.data.delete({id:t,codicent:this.codicent}),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 a.default(t.content).content.split("\n"),o=e[0],n=e.slice(1).join("\n");return{id:t.id,title:o,content:n}})),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.generateApiToken=async(t,e)=>{const a=await fetch(`${o}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText}`);return await a.text()},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,a=100,n=void 0)=>{const i=await this.request(`${o}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:a})});let s=await i.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n){const t=await this.getPublicFlow(n);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let a=[];const o=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:10});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(o)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,a)=>e===a.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,a,n)=>{const i=await fetch(`${o}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:a})});if(!i.ok)return"";const s=await i.text();return window.Codicent.init({token:n,baseUrl:o}),s},this.loginUser=async(t,e)=>{try{const a=await fetch(`${o}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!a.ok)return 404===a.status||400===a.status?null:401===a.status?(this.handleUnauthorized(),null):"";const n=await a.text();return this.setToken(n),n}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,a)=>e===a.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 a=await fetch(`${o}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText||"Failed to add follower!"}`);return await a.json()},this.cloneProject=async(t,e)=>{const a=await fetch(`${o}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText}`);let n=await a.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),a=JSON.parse(e),i=a.sub||a.userId,s=await fetch(`${o}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?(this.handleUnauthorized(),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}),a=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==a&&(console.log("updating instructions",a),await window.Codicent.postMessage({message:a,type:"text",parentId:e[0].id})):(console.log("new instructions",a),await window.Codicent.postMessage({message:a,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const a=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(!a.ok)throw 401===a.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${a.statusText}`);const n=await a.json(),{email:i,picture:s,description:r,followers:c,properties:h,owner:d}=n;return{nickname:t,email:i,name:r,picture:s,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:a,picture:n})=>{const i=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:a,picture:n,description:""})});if(!i.ok)throw i.status,new Error(`${i.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const a=await fetch(`${o}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`requestInvite() => ${a.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const a=await fetch(`${o}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`updateMembersAccess() => ${a.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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:o})},this.getToken=()=>n,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:a}=await e.json();return a},this.redirectToCheckout=async t=>{const a=await e.loadStripe(this.options.STRIPE_PUBLIC_KEY);if(!a)throw new Error("Stripe failed to load");const o=await this.createCheckoutSession(t),{error:n}=await a.redirectToCheckout({sessionId:o});if(n)throw new Error(n.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 a=await e.json();return a=a.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),a},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 a=await e.json();return a.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a},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 a={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},n=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(a)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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],a=atob(t),o=JSON.parse(a).nickname;if(!await this.addFollower(e,o))throw new Error("Failed to add follower: "+o)}catch(t){console.error("Error extracting adding anonymous follower:",t)}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 this.request(`${o}app/GetForms?codicent=${this.codicent}`,"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.getTodoStatus=async t=>{const e=await fetch(`${o}/app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const a=await fetch(`${o}/app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)return console.warn(`updateTodoStatus() => ${a.statusText}`),!1;return await a.json()},this.codicent="",this.options=t}async request(t,e,a={}){const o={};a.headers&&a.headers.forEach((([t,e])=>{o[t]=e}));const n=await fetch(t,{...a,method:e,headers:o});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}}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 a=window.URL.createObjectURL(t),o=document.createElement("a");o.style.display="none",o.href=a,o.download=e.filename,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(a)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",a)=>{const n=await fetch(`${o}app/GetAi2ChatReply?message=${t}&project=${e}${a?"&messageId="+a:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!n.ok)return void n.status;return(await n.json()).content.replace("@codicent-mini","").trim()},exports.CodicentService=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItem.d.ts","sourceRoot":"","sources":["../../../src/components/MessageItem.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2H9C,QAAA,MAAM,WAAW,0HAad;IACD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,
|
|
1
|
+
{"version":3,"file":"MessageItem.d.ts","sourceRoot":"","sources":["../../../src/components/MessageItem.tsx"],"names":[],"mappings":"AA6BA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA2H9C,QAAA,MAAM,WAAW,0HAad;IACD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,4CA+QA,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as r}from"react";import{useNavigate as n}from"react-router-dom";import{CodicentService as s}from"../services/codicent.js";import a from"./Markdown.js";import"./Textarea.js";import"./Button.js";import{Text as l}from"./Text.js";import"./Spinner.js";import"./TextHeader.js";import"./TypingIndicator.js";import"./Dialog.js";import"./ChatInput.js";import"./CombinedPlaceholderDialog.js";import"./ChatMessage.js";import"./Header.js";import m from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as d}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"../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";import"../stores/chatStore.js";import c from"../hooks/useLocalization.js";import"../hooks/useAppStyles.js";import{FileThumbnail as p}from"./FileThumbnail.js";import"./MessageInput.js";import"./UploadFile.js";import"./SnapFooter.js";import"./Profile.js";import"./Content.js";import"./AiInput.js";import"./SearchBox.js";import"./HtmlView.js";import"./Footer.js";import"./Page.js";import{makeStyles as u}from"../node_modules/@griffel/react/makeStyles.esm.js";import{Card as h}from"../node_modules/@fluentui/react-card/lib/components/Card/Card.js";import{Switch as g}from"../node_modules/@fluentui/react-switch/lib/components/Switch/Switch.js";import{FullScreenMaximizeRegular as f}from"../node_modules/@fluentui/react-icons/lib/icons/chunk-2.js";import{ArrowCollapseAllRegular as j,ArrowExpandAllRegular as b}from"../node_modules/@fluentui/react-icons/lib/icons/chunk-0.js";import{CardHeader as x}from"../node_modules/@fluentui/react-card/lib/components/CardHeader/CardHeader.js";import{Skeleton as w}from"../node_modules/@fluentui/react-skeleton/lib/components/Skeleton/Skeleton.js";import{SkeletonItem as S}from"../node_modules/@fluentui/react-skeleton/lib/components/SkeletonItem/SkeletonItem.js";import{Caption1 as k}from"../node_modules/@fluentui/react-text/lib/components/presets/Caption1/Caption1.js";import{tokens as _}from"../node_modules/@fluentui/tokens/lib/tokens.js";import{Edit20Regular as O}from"../node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-7.js";const I=u({iframe:{border:"none",width:"100%",height:"100%"},main:{gap:"36px",display:"flex",flexDirection:"column",flexWrap:"wrap"},card:{minWidth:"300px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",maxHeight:"11em",borderRadius:"10px",position:"relative"},expandedCard:{minWidth:"320px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",borderRadius:"10px",position:"relative"},text:{margin:"0.5em",whiteSpace:"normal",fontSize:"larger"},caption:{color:_.colorNeutralForeground3},headerImage:{borderRadius:"4px",maxWidth:"44px",maxHeight:"44px"},rectangle:{margin:0,top:"-5px",left:"-2px",width:"5px",position:"absolute",height:"100%"},fileList:{display:"flex",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin",msOverflowStyle:"none",padding:"4px",margin:"0 -4px",maxWidth:"100%",boxSizing:"border-box","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:_.colorNeutralStroke1,borderRadius:"3px"}},htmlButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},headerButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},iconButtonRow:{position:"absolute",top:"0.5em",right:"0.5em",display:"flex",alignItems:"center",gap:"0.5em",zIndex:2},content:{overflow:"hidden",transition:"max-height 0.3s ease-out",userSelect:"text"},truncated:{maxHeight:"10em"},header:{display:"flex",flexDirection:"row",gap:"0.5em",alignItems:"center"},todoSwitch:{transform:"scale(0.8)","& .fui-Switch__label":{fontSize:"0.75rem"}}}),E=({header:u,description:_,timestamp:E,text:N,image:v,tags:C,id:T,fileIds:y,codicentService:A,busy:B,onEdit:F,onShowHtmlPreview:L})=>{const R=I(),H=n(),[P,D]=o(!1),[G,z]=o(!1),[M,K]=o("unknown"),[W,$]=o(!1),U=i(null),Y=Object.keys(d("LOGBOOK_TAG_DEFINITIONS")),V=Y.find((e=>C.includes(e)))||(y.length>0?Y.find((e=>"file"===e)):void 0),[X,q]=o([]),J=C.includes("todo"),{t:Q}=c(),Z=["TYPE","CUSTOMER","CONTACT","SALESPERSON","MESSAGE","COMPANY","PHONE","EMAIL","WEBSITE","INFO","FÖRETAG","ROLE","KONTAKT"],ee=[Q("Typ"),Q("Kund"),Q("Kontakt"),Q("Säljare"),Q("Meddelande"),Q("Företag"),Q("Telefon"),Q("E-post"),Q("Hemsida"),Q("Info"),Q("Företag"),Q("Roll"),Q("Kontakt")];r((()=>{Promise.all(y.map((e=>A.getFileInfo(e)))).then((e=>{q(e)}))}),[A,q,y]),r((()=>{const e=()=>{if(U.current){const e=U.current.scrollHeight>100+(X.length>0?-72:0);z(e)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[N,X]),r((()=>{if(J){(async()=>{try{const e=await A.getTodoStatus(T);K(e)}catch(e){console.error("Error loading todo status:",e),K("unknown")}})()}}),[J,T,A]);const te=()=>D(!P),oe=C.includes("chat")&&(N.includes("#function_result")||N.includes("#finish_reason_function_call")),ie=e=>{const t=e.indexOf("```html");if(-1===t)return e;const o=e.indexOf("```",t+7);if(-1===o)return e.substring(t+7);return e.substring(t+7,o)},re=new m(N).data,ne=V&&d("LOGBOOK_TAG_DEFINITIONS")[V].editable,se=V&&d("LOGBOOK_TAG_DEFINITIONS")[V].imageSize||void 0;return e(h,{className:P?R.expandedCard:R.card,style:{backgroundColor:d("MESSAGE_HIDE_BAR")?V?d("LOGBOOK_TAG_DEFINITIONS")[V].color:d("APP_HEADER_COLOR")||"#eee":"#eee"},onClick:C.includes("chat")?e=>{C.includes("chat")&&(e&&e.stopPropagation(),H("/chat?id="+T))}:void 0,children:[!d("MESSAGE_HIDE_BAR")&&t("div",{className:R.rectangle,style:{backgroundColor:V?d("LOGBOOK_TAG_DEFINITIONS")[V].color:d("APP_HEADER_COLOR")||void 0}}),e("div",{className:R.iconButtonRow,children:[J&&t(g,{className:R.todoSwitch,checked:"done"===M,onChange:(e,t)=>(async e=>{if(!W){$(!0);try{const t=e?"done":"undone";await A.updateTodoStatus(T,t)&&K(t)}catch(e){console.error("Error updating todo status:",e)}finally{$(!1)}}})(t.checked),disabled:W||"unknown"===M,label:Q("done"===M?"Done":"Todo")}),ne&&F&&t(O,{className:R.htmlButton,onClick:()=>F()}),L&&!ne&&C.includes("html")&&t(f,{className:R.htmlButton,onClick:e=>{e.stopPropagation(),L(ie(N))}}),G&&!C.includes("chat")&&P&&t(j,{className:R.headerButton,onClick:te}),G&&!C.includes("chat")&&!P&&t(b,{className:R.headerButton,onClick:te})]}),t(x,{image:v?t("img",{className:R.headerImage,src:"app_logo.svg",alt:"User"}):null,header:B?t(w,{style:{width:"50%"},children:t(S,{})}):e("div",{className:R.header,children:[t(l,{weight:"semibold",children:u}),E&&t(l,{weight:"regular",children:E})]}),description:t(k,{className:R.caption,children:_})}),e("div",{ref:U,className:`${R.content} ${P?"":R.truncated}`,children:[X.length>0&&t("div",{className:R.fileList,children:X.map((e=>t(p,{file:e,thumbnailSize:se,getImageUrl:s.getImageUrl,onClick:()=>{e.contentType.startsWith("image")?H(`/image?id=${T}&file=${e.id}`):s.downloadFile(e)}},e.id)))}),B?e(w,{style:{width:"100%"},children:[t(S,{}),t(S,{}),t(S,{}),t(S,{}),t(S,{})]}):t("div",{className:R.text,children:C.includes("html")?t("iframe",{className:R.iframe,title:"html",srcDoc:ie(N),sandbox:"allow-same-origin allow-scripts"}):C.includes("crm")&&0===Object.keys(re).length?t(a,{content:oe?"*Tänker...*":re?(()=>{const e=new RegExp(`(${Z.join("|")})\\s*:\\s*`,"gi");return N.replace(e,((e,t)=>{const o=Z.indexOf(t.toUpperCase());-1===o&&console.log("Field not found:",t);return`\n**${-1!==o?ee[o]:t}:** `})).trim()})():N}):t(a,{content:oe?"*Tänker...*":re&&re&&Object.keys(re).length>0?Object.keys(re).map((e=>{const t=Z.indexOf(e.toUpperCase());return`**${-1!==t?ee[t]:e}:** ${re[e]}\n`})).join("\n"):N})})]})]})};export{E as default};
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as o,useRef as i,useEffect as r}from"react";import{useNavigate as n}from"react-router-dom";import{CodicentService as s}from"../services/codicent.js";import a from"./Markdown.js";import"./Textarea.js";import"./Button.js";import{Text as l}from"./Text.js";import"./Spinner.js";import"./TextHeader.js";import"./TypingIndicator.js";import"./Dialog.js";import"./ChatInput.js";import"./CombinedPlaceholderDialog.js";import"./ChatMessage.js";import"./Header.js";import m from"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as d}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"../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";import"../stores/chatStore.js";import c from"../hooks/useLocalization.js";import"../hooks/useAppStyles.js";import{FileThumbnail as p}from"./FileThumbnail.js";import"./MessageInput.js";import"./UploadFile.js";import"./SnapFooter.js";import"./Profile.js";import"./Content.js";import"./AiInput.js";import"./SearchBox.js";import"./HtmlView.js";import"./Footer.js";import"./Page.js";import{makeStyles as u}from"../node_modules/@griffel/react/makeStyles.esm.js";import{Card as h}from"../node_modules/@fluentui/react-card/lib/components/Card/Card.js";import{Switch as g}from"../node_modules/@fluentui/react-switch/lib/components/Switch/Switch.js";import{FullScreenMaximizeRegular as f}from"../node_modules/@fluentui/react-icons/lib/icons/chunk-2.js";import{ArrowCollapseAllRegular as j,ArrowExpandAllRegular as b}from"../node_modules/@fluentui/react-icons/lib/icons/chunk-0.js";import{CardHeader as x}from"../node_modules/@fluentui/react-card/lib/components/CardHeader/CardHeader.js";import{Skeleton as w}from"../node_modules/@fluentui/react-skeleton/lib/components/Skeleton/Skeleton.js";import{SkeletonItem as S}from"../node_modules/@fluentui/react-skeleton/lib/components/SkeletonItem/SkeletonItem.js";import{Caption1 as k}from"../node_modules/@fluentui/react-text/lib/components/presets/Caption1/Caption1.js";import{tokens as _}from"../node_modules/@fluentui/tokens/lib/tokens.js";import{Edit20Regular as O}from"../node_modules/@fluentui/react-icons/lib/sizedIcons/chunk-7.js";const I=u({iframe:{border:"none",width:"100%",height:"100%"},main:{gap:"36px",display:"flex",flexDirection:"column",flexWrap:"wrap"},card:{minWidth:"300px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",maxHeight:"11em",borderRadius:"10px",position:"relative"},expandedCard:{minWidth:"320px",maxWidth:"100%",height:"fit-content",marginBottom:"1em",paddingLeft:"1em",borderRadius:"10px",position:"relative"},text:{margin:"0.5em",whiteSpace:"normal",fontSize:"larger"},caption:{color:_.colorNeutralForeground3},headerImage:{borderRadius:"4px",maxWidth:"44px",maxHeight:"44px"},rectangle:{margin:0,top:"-5px",left:"-2px",width:"5px",position:"absolute",height:"100%"},fileList:{display:"flex",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"thin",msOverflowStyle:"none",padding:"4px",margin:"0 -4px",maxWidth:"100%",boxSizing:"border-box","&::-webkit-scrollbar":{height:"6px"},"&::-webkit-scrollbar-track":{background:"transparent"},"&::-webkit-scrollbar-thumb":{backgroundColor:_.colorNeutralStroke1,borderRadius:"3px"}},htmlButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},headerButton:{fontSize:"1.5em",cursor:"pointer",marginLeft:"0.5em"},iconButtonRow:{position:"absolute",top:"0.5em",right:"0.5em",display:"flex",alignItems:"center",gap:"0.5em",zIndex:2},content:{overflow:"hidden",transition:"max-height 0.3s ease-out",userSelect:"text"},truncated:{maxHeight:"10em"},header:{display:"flex",flexDirection:"row",gap:"0.5em",alignItems:"center"},todoSwitch:{transform:"scale(0.8)","& .fui-Switch__label":{fontSize:"0.75rem"}}}),E=({header:u,description:_,timestamp:E,text:N,image:v,tags:C,id:T,fileIds:y,codicentService:A,busy:B,onEdit:F,onShowHtmlPreview:L})=>{const R=I(),H=n(),[P,D]=o(!1),[G,z]=o(!1),[M,K]=o("unknown"),[W,$]=o(!1),U=i(null),Y=Object.keys(d("LOGBOOK_TAG_DEFINITIONS")),V=Y.find((e=>C.includes(e)))||(y.length>0?Y.find((e=>"file"===e)):void 0),[X,q]=o([]),J=C.includes("todo"),{t:Q}=c(),Z=["TYPE","CUSTOMER","CONTACT","SALESPERSON","MESSAGE","COMPANY","PHONE","EMAIL","WEBSITE","INFO","FÖRETAG","ROLE","KONTAKT"],ee=[Q("Typ"),Q("Kund"),Q("Kontakt"),Q("Säljare"),Q("Meddelande"),Q("Företag"),Q("Telefon"),Q("E-post"),Q("Hemsida"),Q("Info"),Q("Företag"),Q("Roll"),Q("Kontakt")];r((()=>{Promise.all(y.map((e=>A.getFileInfo(e)))).then((e=>{q(e)}))}),[A,q,y]),r((()=>{const e=()=>{if(U.current){const e=U.current.scrollHeight>100+(X.length>0?-72:0);z(e)}};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)}),[N,X]),r((()=>{if(J){(async()=>{try{const e=await A.getTodoStatus(T);K(e)}catch(e){console.error("Error loading todo status:",e),K("unknown")}})()}}),[J,T,A]);const te=()=>D(!P),oe=C.includes("chat")&&(N.includes("#function_result")||N.includes("#finish_reason_function_call")),ie=e=>{const t=e.indexOf("```html");if(-1===t)return e;const o=e.indexOf("```",t+7);if(-1===o)return e.substring(t+7);return e.substring(t+7,o)},re=new m(N).data,ne=V&&d("LOGBOOK_TAG_DEFINITIONS")[V].editable,se=V&&d("LOGBOOK_TAG_DEFINITIONS")[V].imageSize||void 0;return e(h,{className:P?R.expandedCard:R.card,style:{backgroundColor:d("MESSAGE_HIDE_BAR")?V?d("LOGBOOK_TAG_DEFINITIONS")[V].color:d("APP_HEADER_COLOR")||"#eee":"#eee"},onClick:C.includes("chat")?e=>{C.includes("chat")&&(e&&e.stopPropagation(),H("/chat?id="+T))}:void 0,children:[!d("MESSAGE_HIDE_BAR")&&t("div",{className:R.rectangle,style:{backgroundColor:V?d("LOGBOOK_TAG_DEFINITIONS")[V].color:d("APP_HEADER_COLOR")||void 0}}),e("div",{className:R.iconButtonRow,children:[J&&t(g,{className:R.todoSwitch,checked:"done"===M,onChange:(e,t)=>(async e=>{if(!W){$(!0);try{const t=e?"done":"undone";await A.updateTodoStatus(T,t)&&K(t)}catch(e){console.error("Error updating todo status:",e)}finally{$(!1)}}})(t.checked),disabled:W||"unknown"===M,label:Q("done"===M?"Done":"Todo")}),ne&&F&&t(O,{className:R.htmlButton,onClick:()=>F()}),L&&!ne&&C.includes("html")&&t(f,{className:R.htmlButton,onClick:e=>{e.stopPropagation(),L(ie(N))}}),G&&!C.includes("chat")&&P&&t(j,{className:R.headerButton,onClick:te}),G&&!C.includes("chat")&&!P&&t(b,{className:R.headerButton,onClick:te})]}),t(x,{image:v?t("img",{className:R.headerImage,src:"app_logo.svg",alt:"User"}):null,header:B?t(w,{style:{width:"50%"},children:t(S,{})}):e("div",{className:R.header,children:[t(l,{weight:"semibold",children:u}),E&&t(l,{weight:"regular",children:E})]}),description:t(k,{className:R.caption,children:_})}),e("div",{ref:U,className:`${R.content} ${P?"":R.truncated}`,children:[X.length>0&&t("div",{className:R.fileList,children:X.map((e=>t(p,{file:e,thumbnailSize:se,getImageUrl:s.getImageUrl,onClick:()=>{e.contentType.startsWith("image")?H(`/image?id=${T}&file=${e.id}`):s.downloadFile(e)}},e.id)))}),B?e(w,{style:{width:"100%"},children:[t(S,{}),t(S,{}),t(S,{}),t(S,{}),t(S,{})]}):t("div",{className:R.text,children:C.includes("html")?t("iframe",{className:R.iframe,title:"html",srcDoc:ie(N),sandbox:"allow-same-origin allow-scripts"}):C.includes("crm")&&0===Object.keys(re).length?t(a,{content:oe?"*"+Q("Tänker")+"...*":re?(()=>{const e=new RegExp(`(${Z.join("|")})\\s*:\\s*`,"gi");return N.replace(e,((e,t)=>{const o=Z.indexOf(t.toUpperCase());-1===o&&console.log("Field not found:",t);return`\n**${-1!==o?ee[o]:t}:** `})).trim()})():N}):t(a,{content:oe?"*"+Q("Tänker")+"...*":re&&re&&Object.keys(re).length>0?Object.keys(re).map((e=>{const t=Z.indexOf(e.toUpperCase());return`**${-1!==t?ee[t]:e}:** ${re[e]}\n`})).join("\n"):N})})]})]})};export{E as default};
|
|
@@ -114,6 +114,11 @@ export interface AppConfigOptions {
|
|
|
114
114
|
FORM_BACKGROUND_IMAGE_URL: undefined | string;
|
|
115
115
|
AUTO_TRANSLATE: boolean;
|
|
116
116
|
FORCE_LANGUAGE: string | undefined;
|
|
117
|
+
TRANSLATIONS: {
|
|
118
|
+
[key: string]: {
|
|
119
|
+
[key: string]: string;
|
|
120
|
+
};
|
|
121
|
+
} | undefined;
|
|
117
122
|
APP_LOGBOOK_TITLE: undefined | string;
|
|
118
123
|
LOGIN_WELCOME_TEXT: string | undefined;
|
|
119
124
|
LOGIN_HIDE_WELCOME: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/config/index.ts"],"names":[],"mappings":"AAGA,qBAAa,SAAS;;IAKpB,iBAAiB,EAAE,MAAM,CAAM;IAC/B,2BAA2B,EAAE,MAAM,CAAM;IACzC,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,OAAO,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,GAAG,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YAC1C,KAAK,EAAE;gBAAE,EAAE,EAAE,MAAM,CAAC;gBAAC,KAAK,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,EAAE,CAAC;YACxD,iBAAiB,EAAE,MAAM,CAAC;YAC1B,YAAY,CAAC,EAAE,OAAO,CAAC;YACvB,gBAAgB,EAAE,MAAM,CAAC;YACzB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;SACtB,CAAC;KACH,CAAC;CAyBH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,SAAS,GAA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G,SAAS,CAAC;IACnC,YAAY,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,SAAS,CAAC;IAIvE,iBAAiB,EAAE,SAAS,GAAG,MAAM,CAAC;IACtC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,yBAAyB,EAAE,OAAO,CAAC;IACnC,oBAAoB,EAAE,SAAS,GAAG,MAAM,CAAC;IACzC,2BAA2B,EAAE,OAAO,CAAC;CACtC;AAuHD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAG5F;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,GAAE,OAAO,CAAC,gBAAgB,CAAM,QAgBtE"}
|
package/dist/esm/config/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import _ from"../node_modules/mermaid/dist/mermaid.core.js";class
|
|
1
|
+
import _ from"../node_modules/mermaid/dist/mermaid.core.js";class T{constructor(){this.CHAT_INSTRUCTIONS="",this.REALTIME_VOICE_INSTRUCTIONS="",this.apps={}}}const O={LOGIN_REDIRECT:!1,ABOUT_TEXT:"Codicent APP SDK",ANONYMOUS_CODICENT:void 0,ANONYMOUS_TOKEN:void 0,API_BASE_URL:"https://codicent.com/",APP_BUTTONS:void 0,APP_CHAT_TEXT_PLACEHOLDER:void 0,APP_CHAT_TITLE:void 0,APP_CONFIG:new T,APP_FOOTER_COLOR:void 0,APP_FOOTER_SELECTED_COLOR:void 0,APP_FOOTER_TEXT_COLOR:void 0,APP_HEADER_COLOR:void 0,APP_HEADER_ICON_URL:void 0,APP_HEADER_TEXT_COLOR:void 0,APP_ICON_URL:void 0,APP_LOG_CODICENT:"",APP_LOG_TOKEN:"",APP_LOGBOOK_TITLE:void 0,APP_MENU_TITLE:void 0,APP_NAME:void 0,APP_PREFIX:void 0,APP_SAVE_TITLE:void 0,APP_SEARCH_TITLE:void 0,APP_SLOGAN:void 0,APP_SPLASH_TEXT:void 0,APP_SPLASH_URL:void 0,APP_TEMPLATE:"",APP_TITLE:void 0,AUTH_REDIRECT_URL:void 0,AUTH0_AUDIENCE:"https://codicent.com/api",AUTH0_CLIENT_ID:"80STzWmmzN3Tgf76HgFRyv54keYmvnaw",AUTH0_DOMAIN:"auth.codicent.com",AUTH0_PROVIDER_SCOPE:"read:current_user update:current_user_metadata openid profile email",AUTH0_SCOPE:"read:current_user",AUTH0_USER_DOMAIN:void 0,BUTTON_ACTIVE_COLOR:void 0,BUTTON_BACKGROUND_COLOR:void 0,BUTTON_BORDER_RADIUS:void 0,BUTTON_HOVER_COLOR:void 0,BUTTON_TAG:"app-button",BUTTON_TEXT_COLOR:void 0,CHAT_BACKGROUND_IMAGE_URL:void 0,CHAT_BOT_BACKGROUND_COLOR:void 0,CHAT_BOT_TEXT_COLOR:void 0,CHAT_INSTRUCTIONS:void 0,CHAT_USER_BACKGROUND_COLOR:void 0,CHAT_USER_TEXT_COLOR:void 0,CHAT_WELCOME:"Welcome",COMPOSE_BACKGROUND_IMAGE_URL:void 0,COMPOSE_HIDE_LOCATION:void 0,COMPOSE_SIMPLE_ATTACH_FILE:void 0,DEFAULT_LANGUAGE:"en",HIDE_CHAT_BUTTON:!1,HIDE_MENU_BUTTON:!1,HIDE_REGISTER_BUTTON:!1,HIDE_SAVE_BUTTON:!1,HOME_BACKGROUND_IMAGE_URL:void 0,INDEX_TITLE:void 0,LOGBOOK_TAG_DEFINITIONS:{},LOGBOOK_TAGS:"[]",MENU_BACKGROUND_IMAGE_URL:void 0,MESSAGE_HIDE_BAR:!1,MODULE_VOICE:!1,PUBLIC_FLOW_CODICENT:void 0,REALTIME_VOICE_API_KEY:"",SEND_BUTTON_ROUND_BACKGROUND:!1,SHOW_CANVAS_BUTTON:!1,SHOW_CHAT_PROMPTS:!1,SHOW_HELP_BUTTON:!1,SHOW_LOGBOOK_BUTTON:!1,SHOW_MICROPHONE_BUTTON:!1,SHOW_SETTINGS_BUTTON:!1,SHOW_SNAP_BUTTON:!1,SHOW_VOICE_BUTTON:!1,STRIP_CUSTOMER_PORTAL:"",STRIPE_PRICE_ID:"",STRIPE_PUBLIC_KEY:"",SUBSCRIPTION_NEEDED:!1,THEME_WELCOME:void 0,USER_PREFIX:void 0,WELCOME_STATUS_PROMPT:"",SHOW_SEND_BUTTON_TEXT:!1,SHOW_SAVE_BUTTON_TEXT:!1,FORM_BACKGROUND_IMAGE_URL:void 0,AUTO_TRANSLATE:!0,FORCE_LANGUAGE:void 0,TRANSLATIONS:void 0,LOGIN_WELCOME_TEXT:void 0,LOGIN_HIDE_WELCOME:!1,LOGIN_LOGO_URL:void 0,HIDE_CHAT_ADD_FILE_BUTTON:!1,FORM_ACCEPT_MARKDOWN:void 0,RESTART_AUDIO_ON_TAKE_PHOTO:!1};const E=function(_){return new Proxy(_,{get:(_,T,O)=>Reflect.get(_,T,O)})}(O);function A(_){return E[_]}function N(T={}){for(const[_,E]of Object.entries(T))void 0!==E&&(O[_]=E);void 0!==T.TRANSLATIONS&&(globalThis.__CODICENT_REINIT_I18N__=!0),_.initialize({startOnLoad:!1})}export{T as AppConfig,A as getConfigValue,N as initCodicentApp};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalization.d.ts","sourceRoot":"","sources":["../../../src/hooks/useLocalization.ts"],"names":[],"mappings":"AAOA,UAAU,cAAc;IACtB,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;
|
|
1
|
+
{"version":3,"file":"useLocalization.d.ts","sourceRoot":"","sources":["../../../src/hooks/useLocalization.ts"],"names":[],"mappings":"AAOA,UAAU,cAAc;IACtB,MAAM,EAAE,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,CAAC;IAC7D,QAAQ,EAAE,MAAM,CAAC;CAClB;AAgGD,eAAO,MAAM,gBAAgB,YAAiB,CAAC;AAE/C,QAAA,MAAM,eAAe;aAuCX,MAAM;;+BAlByB,MAAM;;;CAmF9C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as
|
|
1
|
+
import{useState as t,useRef as e,useEffect as n,useCallback as r}from"react";import a from"../node_modules/i18next/dist/esm/i18next.js";import{CodicentService as o}from"../services/codicent.js";import{getConfigValue as s}from"../config/index.js";import{initReactI18next as i}from"../node_modules/react-i18next/dist/es/initReactI18next.js";import{useTranslation as l}from"../node_modules/react-i18next/dist/es/useTranslation.js";const c=()=>{const t=s("FORCE_LANGUAGE");if(t)return{source:"force_config",language:t};if("undefined"!=typeof window){const t=new URLSearchParams(window.location.search),e=t.get("lang")||t.get("language");if(e)return{source:"url_param",language:e}}if("undefined"!=typeof navigator&&navigator.language){return{source:"browser",language:navigator.language.split("-")[0]}}return{source:"default",language:s("DEFAULT_LANGUAGE")||"sv"}};let u=null;const g=()=>{if(null===u){const{language:t}=c();u=t}return u},d=()=>{const t=s("TRANSLATIONS");if(t){const e={};for(const[n,r]of Object.entries(t))e[n]={translation:r};return e}return{en:{translation:{Hello:"Hello"}},sv:{translation:{Hello:"Hej"}}}},f=()=>{if(a.isInitialized){const t=d();Object.keys(t).forEach((e=>{a.addResourceBundle(e,"translation",t[e].translation,!0,!0)}))}else a.use(i).init({resources:d(),lng:g(),fallbackLng:s("DEFAULT_LANGUAGE")||"sv",interpolation:{escapeValue:!1}})};f();const m=()=>{const{t:a,i18n:i}=l(),[u,d]=t((()=>g())),[m,_]=t(JSON.parse(localStorage.getItem("app-translations")||"{}")),p=e([]);n((()=>{globalThis.__CODICENT_REINIT_I18N__&&(f(),globalThis.__CODICENT_REINIT_I18N__=!1)}),[]),n((()=>{i.changeLanguage(u)}),[u,i]);const L=r((t=>{const{source:e}=c();"force_config"!==e?"url_param"!==e?d(t):console.warn("Language setting ignored due to URL parameter"):console.warn("Language setting ignored due to FORCE_LANGUAGE configuration")}),[]),N=r((()=>c()),[]);return{t:r((t=>(i.exists(t)||(async(t,e)=>{const n=`${e} - ${t}`;let r=m[e]?.[t]||void 0;return s("AUTO_TRANSLATE")&&!r&&-1===p.current.indexOf(n)&&(p.current=[...p.current,n],localStorage.setItem("app-translations",JSON.stringify(m)),r=await o.getMiniChatReply(`Översätt '${t}' till språk '${e}' och svara endast med översättningen.`),r&&r.includes("Error code:")&&(r=void 0),r&&(!t.trim().startsWith('"')&&r.trim().startsWith('"')&&r.trim().endsWith('"')&&(r=r.trim().slice(1,-1)),!t.trim().startsWith("'")&&r.trim().startsWith("'")&&r.trim().endsWith("'")&&(r=r.trim().slice(1,-1)),m[e]={...m[e],[t]:r},localStorage.setItem("app-translations",JSON.stringify(m)),_(m))),r||t})(t,u).then((e=>{i.addResource(u,"translation",t,e)})),a(t))),[i,a,m,u]),currentLanguage:u,setCurrentLanguage:L,getLanguageInfo:N,isForced:["force_config","url_param"].includes(c().source)}};export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAccept.d.ts","sourceRoot":"","sources":["../../../src/pages/FormAccept.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormAccept.d.ts","sourceRoot":"","sources":["../../../src/pages/FormAccept.tsx"],"names":[],"mappings":"AAiCA,QAAA,MAAM,UAAU,+CAkDf,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormInvite.d.ts","sourceRoot":"","sources":["../../../src/pages/FormInvite.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,OAAO,EAAE,gBAAgB,EAA6C,MAAM,UAAU,CAAC;AAsCvF,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"FormInvite.d.ts","sourceRoot":"","sources":["../../../src/pages/FormInvite.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAG3B,OAAO,EAAE,gBAAgB,EAA6C,MAAM,UAAU,CAAC;AAsCvF,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC;IAAE,KAAK,EAAE,gBAAgB,CAAA;CAAE,CA+I/C,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,jsxs as e,Fragment as
|
|
1
|
+
import{jsx as o,jsxs as e,Fragment as n}from"react/jsx-runtime";import{useState as t,useEffect as r}from"react";import"../components/Markdown.js";import"../components/Textarea.js";import{Button as i}from"../components/Button.js";import{Title as a}from"../components/Title.js";import"../components/Spinner.js";import{Label as s}from"../components/Label.js";import{Input as l}from"../components/Input.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 m from"../hooks/useStateWithLocalStorage.js";import"../services/codicent.js";import"../utils/MessageContent.js";import"../node_modules/tinycolor2/esm/tinycolor.js";import"../_virtual/index.js";import{getConfigValue as p}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{formatGuidToShorterReadableCode as c}from"../utils/helpers.js";import"./AppFrame.js";import"./Snap.js";import"./Search.js";import"./Login.js";import"./CrmPage.js";import"./ImageView.js";import"./FormAccept.js";import"./Sales.js";import"../stores/chatStore.js";import d from"../hooks/useLocalization.js";import"../hooks/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 u from"../components/Content.js";import"../components/AiInput.js";import"../components/SearchBox.js";import"../components/HtmlView.js";import"../components/Footer.js";import{Page as h}from"../components/Page.js";import{makeStyles as k}from"../node_modules/@griffel/react/makeStyles.esm.js";import{useId as j}from"../node_modules/@fluentui/react-utilities/lib/hooks/useId.js";import{Dropdown as g}from"../node_modules/@fluentui/react-combobox/lib/components/Dropdown/Dropdown.js";import{Option as f}from"../node_modules/@fluentui/react-combobox/lib/components/Option/Option.js";const v=k({inputAndButton:{display:"flex",gap:"10px"},input:{minWidth:"90%"},container:{maxWidth:"640px",margin:"0 auto",backgroundPosition:"calc(50% + 100px) center",backgroundRepeat:"no-repeat",backgroundSize:"contain",height:"100%"},generatedLinkTitle:{marginBottom:"0.5em",fontWeight:"bold"},orderedList:{marginLeft:"20px",marginBottom:"1em"},instructionParagraph:{marginBottom:"1em",fontWeight:"bold"}}),b=({state:k})=>{const b=v(),{service:w}=k,{t:x}=d(),[S,y]=m(k.context.selectedApp+"_forms",[]),[$,_]=t(),[C,L]=t(),[A,I]=t(!1),[T,D]=t(),N=j("form-dropdown");r((()=>{w.getForms().then((o=>{o.sort(((o,e)=>o.name.localeCompare(e.name))),y(o)}))}),[w,x,y]);const B=void 0!==navigator.share;return o(h,{children:o("div",{className:b.container,style:{backgroundImage:`url(${p("COMPOSE_BACKGROUND_IMAGE_URL")})`},children:e(u,{children:[o(a,{children:x("Skapa länk till formulär")}),o("p",{className:b.instructionParagraph,children:x("Instruktioner")}),e("ol",{className:b.orderedList,children:[o("li",{children:x("Välj ett formulär från rullgardinsmenyn nedan. Detta formulär kommer att användas för den genererade länken.")}),o("li",{children:x("Klicka på 'Skapa länk' för att generera en unik länk. Länken visar var aktiv och kan användas för att svara på formuläret.")}),o("li",{children:x("När länken visas, kan du klicka på kopiera-ikonen för att kopiera länken till ditt urklipp.")}),o("li",{children:x("Om din enhet stödjer det, kan du även använda dela-knappen för att dela länken direkt.")}),o("li",{children:x("Kom ihåg att spara (skriva ner) koden")})]}),o("label",{id:N,className:b.instructionParagraph,children:x("Välj formulär")}),o(g,{"aria-labelledby":N,placeholder:"-",onOptionSelect:(o,e)=>D(e.optionValue),children:S.map((o=>e(f,{value:o.name,text:`${o.title} (${o.name})`,children:[`${o.title} (${o.name})`," "]},o.name)))}),o(i,{appearance:"primary",disabled:!T,onClick:()=>{const o=S.find((o=>o.name===T));o?.url?w.sendMessage(`#ss-link #${T}`).then((e=>{const n=new Date(Date.now()+2592e5);w.generateApiToken(n).then((n=>{const t=o.url.includes("?")?"&":"?",r=`${o.url}${t}token=${n}`;_(r);const i=c(e);L(i)}))})):w.sendMessage(`#ss-link #${T}`).then((o=>{const e=`${window.location.protocol}//${window.location.hostname}${window.location.port?":"+window.location.port:""}${window.location.pathname}`;_(`${e}#/formaccept?id=${o}`);const n=c(o);L(n)}))},children:x("Skapa länk")}),$&&e(n,{children:[o("p",{className:b.generatedLinkTitle,children:x("Här är din genererade länk (du kan kopiera eller dela den):")}),o("div",{className:b.inputAndButton,children:o(l,{className:b.input,value:$,readOnly:!0,onFocus:o=>o.target.select()})}),o("br",{}),e("div",{className:b.inputAndButton,children:[o(i,{appearance:"primary",title:x("Kopiera länk"),icon:"CopyRegular",onClick:()=>{$&&(navigator.clipboard.writeText($),I(!0),setTimeout((()=>{I(!1),_(void 0)}),2e3))},children:x("Kopiera")}),B&&o(i,{appearance:"primary",title:x("Dela länk"),icon:"ShareRegular",onClick:()=>{$&&(navigator.share({url:$}),setTimeout((()=>{_(void 0)}),2e3))},children:x("Dela")})]}),A&&o(s,{children:x("Länk kopierad!")})]})]})})})};export{b as default};
|
|
@@ -61,6 +61,7 @@ export declare class CodicentService {
|
|
|
61
61
|
getFileInfo: (fileId: string) => Promise<FileInfo>;
|
|
62
62
|
static getImageUrl: (fileId: string, width: number) => string;
|
|
63
63
|
static getFileUrl: (fileId: string, extension?: string) => string;
|
|
64
|
+
generateApiToken: (expires?: Date, forUserNickname?: string) => Promise<string>;
|
|
64
65
|
sendMessage: (message: string, parentId?: string) => Promise<string>;
|
|
65
66
|
chat: (message: string, messageId?: string) => Promise<ChatMessageReply>;
|
|
66
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codicent.d.ts","sourceRoot":"","sources":["../../../src/services/codicent.ts"],"names":[],"mappings":"AAkCA,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;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,q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,OAAO,CAAC,IAAI,EAAE,CAAC,CAMlC;IAEF,WAAW,OAAc,MAAM,kBAO7B;IAGF,OAAO,CAAC,kBAAkB;IAM1B,aAAa,cAAqB,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,CAiB/E;IAEF,gBAAgB,cAAqB,MAAM,UAAU,MAAM,GAAG,QAAQ,sBAcpE;CACH"}
|
|
@@ -1 +1 @@
|
|
|
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 a;let o="https://codicent.com/",n="-";const i=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:n,baseUrl:o}),!0);let s=i();if(!s){const t=setInterval((()=>{s=i(),s&&clearInterval(t)}),100)}class r{constructor(a){this.createDataMessage=async(t,e)=>await window.Codicent.data.create({codicent:this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e)=>await window.Codicent.data.read({codicent:this.codicent,tag:t,search:e}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e)=>await window.Codicent.data.update({id:t,data:e,codicent:this.codicent}),this.deleteDataMessage=async t=>await window.Codicent.data.delete({id:t,codicent:this.codicent}),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 a=new e(t.content).content.split("\n"),o=a[0],n=a.slice(1).join("\n");return{id:t.id,title:o,content:n}})),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,a=100,n=void 0)=>{const i=await this.request(`${o}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:a})});let s=await i.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n){const t=await this.getPublicFlow(n);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let a=[];const o=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:10});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(o)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,a)=>e===a.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,a,n)=>{const i=await fetch(`${o}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:a})});if(!i.ok)return"";const s=await i.text();return window.Codicent.init({token:n,baseUrl:o}),s},this.loginUser=async(t,e)=>{try{const a=await fetch(`${o}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!a.ok)return 404===a.status||400===a.status?null:401===a.status?(this.handleUnauthorized(),null):"";const n=await a.text();return this.setToken(n),n}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();return e.filter(((t,e,a)=>e===a.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 a=await fetch(`${o}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText||"Failed to add follower!"}`);return await a.json()},this.cloneProject=async(t,e)=>{const a=await fetch(`${o}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText}`);let n=await a.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),a=JSON.parse(e),i=a.sub||a.userId,s=await fetch(`${o}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?(this.handleUnauthorized(),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}),a=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==a&&(console.log("updating instructions",a),await window.Codicent.postMessage({message:a,type:"text",parentId:e[0].id})):(console.log("new instructions",a),await window.Codicent.postMessage({message:a,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const a=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(!a.ok)throw 401===a.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${a.statusText}`);const n=await a.json(),{email:i,picture:s,description:r,followers:c,properties:h,owner:d}=n;return{nickname:t,email:i,name:r,picture:s,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:a,picture:n})=>{const i=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:a,picture:n,description:""})});if(!i.ok)throw i.status,new Error(`${i.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const a=await fetch(`${o}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`requestInvite() => ${a.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const a=await fetch(`${o}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`updateMembersAccess() => ${a.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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:o})},this.getToken=()=>n,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:a}=await e.json();return a},this.redirectToCheckout=async e=>{const a=await t(this.options.STRIPE_PUBLIC_KEY);if(!a)throw new Error("Stripe failed to load");const o=await this.createCheckoutSession(e),{error:n}=await a.redirectToCheckout({sessionId:o});if(n)throw new Error(n.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 a=await e.json();return a=a.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),a},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 a=await e.json();return a.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a},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 a={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},n=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(a)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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],a=atob(t),o=JSON.parse(a).nickname;if(!await this.addFollower(e,o))throw new Error("Failed to add follower: "+o)}catch(t){console.error("Error extracting adding anonymous follower:",t)}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 this.request(`${o}app/GetForms?codicent=${this.codicent}`,"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.getTodoStatus=async t=>{const e=await fetch(`${o}/app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const a=await fetch(`${o}/app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)return console.warn(`updateTodoStatus() => ${a.statusText}`),!1;return await a.json()},this.codicent="",this.options=a}async request(t,e,a={}){const o={};a.headers&&a.headers.forEach((([t,e])=>{o[t]=e}));const n=await fetch(t,{...a,method:e,headers:o});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}}a=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 t=>{fetch(a.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 a=window.URL.createObjectURL(e),o=document.createElement("a");o.style.display="none",o.href=a,o.download=t.filename,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(a)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",a)=>{const n=await fetch(`${o}app/GetAi2ChatReply?message=${t}&project=${e}${a?"&messageId="+a:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!n.ok)return void n.status;return(await n.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 a;let o="https://codicent.com/",n="-";const i=()=>void 0!==window.Codicent&&(window.Codicent.handleMessage=function(t){const e=new CustomEvent("codicent-log",{detail:{message:t}});window.dispatchEvent(e)},window.Codicent.init({token:n,baseUrl:o}),!0);let s=i();if(!s){const t=setInterval((()=>{s=i(),s&&clearInterval(t)}),100)}class r{constructor(a){this.createDataMessage=async(t,e)=>await window.Codicent.data.create({codicent:this.codicent,tag:t,data:e}),this.readDataMessages=async(t,e)=>await window.Codicent.data.read({codicent:this.codicent,tag:t,search:e}),this.readOneDataMessage=async t=>await window.Codicent.data.readOne(t),this.updateDataMessage=async(t,e)=>await window.Codicent.data.update({id:t,data:e,codicent:this.codicent}),this.deleteDataMessage=async t=>await window.Codicent.data.delete({id:t,codicent:this.codicent}),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 a=new e(t.content).content.split("\n"),o=a[0],n=a.slice(1).join("\n");return{id:t.id,title:o,content:n}})),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.generateApiToken=async(t,e)=>{const a=await fetch(`${o}api/GenerateApiToken?project=${this.codicent}${t?`&expires=${t.toISOString()}`:""}${e?`&forUserNickname=${e}`:""}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText}`);return await a.text()},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,a=100,n=void 0)=>{const i=await this.request(`${o}app/AppGetMessages`,"POST",{headers:[["Authorization",`Bearer ${this.getToken()}`],["Content-Type","application/json; charset=utf-8"]],body:JSON.stringify({tags:t,codicent:this.codicent,search:e,length:a})});let s=await i.json();if(s.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),n){const t=await this.getPublicFlow(n);s=s.concat(t),s.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime()))}return s},this.getMessages=async(t,e)=>{let a=[];const o=t.map((async t=>{const e=await window.Codicent.getMessages({search:`@${this.codicent} #${t}`,length:10});return"chat"===t&&e.forEach((t=>t.content=`#chat\n${t.content}`)),e}));if((await Promise.all(o)).forEach((t=>{a=a.concat(t)})),e)try{const t=await this.getPublicFlow(e);a=a.concat(t)}catch(t){console.warn("Error fetching public flow, PUBLIC_TAG missing in codicent?",t)}return a=a.filter(((t,e,a)=>e===a.findIndex((e=>e.id===t.id)))),a.sort(((t,e)=>e.createdAt.getTime()-t.createdAt.getTime())),a},this.registerUser=async(t,e,a,n)=>{const i=await fetch(`${o}app/RegisterAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${n}`]],body:JSON.stringify({nickname:t,email:e,userId:a})});if(!i.ok)return"";const s=await i.text();return window.Codicent.init({token:n,baseUrl:o}),s},this.loginUser=async(t,e)=>{try{const a=await fetch(`${o}app/LoginAuth0User`,{method:"POST",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${e}`]],body:JSON.stringify({userId:t})});if(!a.ok)return 404===a.status||400===a.status?null:401===a.status?(this.handleUnauthorized(),null):"";const n=await a.text();return this.setToken(n),n}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();return e.filter(((t,e,a)=>e===a.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 a=await fetch(`${o}app/AddFollower?nickname=${t}&followerNickname=${e}`,{method:"GET",headers:[["Content-Type","application/json; charset=utf-8"],["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText||"Failed to add follower!"}`);return await a.json()},this.cloneProject=async(t,e)=>{const a=await fetch(`${o}app/CloneProject?project=${t}&newProject=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)throw a.status,new Error(`${a.statusText}`);let n=await a.json();if(n){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"})||(n=!1)}catch{n=!1}if(n){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"})||(n=!1)}catch{n=!1}}}return n},this.getNickname=async()=>{try{const t=n.split(".")[1],e=atob(t),a=JSON.parse(e),i=a.sub||a.userId,s=await fetch(`${o}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?(this.handleUnauthorized(),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}),a=`@${this.codicent} #instructions\n${t}`;e.length>0?e[0].content!==a&&(console.log("updating instructions",a),await window.Codicent.postMessage({message:a,type:"text",parentId:e[0].id})):(console.log("new instructions",a),await window.Codicent.postMessage({message:a,type:"text"}))}catch{console.warn("Error updating chat instructions")}},this.getUserInfo=async(t,e=!1)=>{const a=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(!a.ok)throw 401===a.status?(this.handleUnauthorized(),new Error("Unauthorized")):new Error(`${a.statusText}`);const n=await a.json(),{email:i,picture:s,description:r,followers:c,properties:h,owner:d}=n;return{nickname:t,email:i,name:r,picture:s,followers:c,properties:h,owner:d}},this.updateUserInfo=async({nickname:t,email:e,name:a,picture:n})=>{const i=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:a,picture:n,description:""})});if(!i.ok)throw i.status,new Error(`${i.statusText}`);return await this.getUserInfo(t,!0)},this.requestInvite=async(t,e)=>{const a=await fetch(`${o}/app/CreateInvitationOrRequest?forUserNickname=${t}&toProjectNickname=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`requestInvite() => ${a.statusText}`),!1)},this.getProjectInfo=this.getUserInfo,this.updateMembersAccess=async(t,e)=>{const a=await fetch(`${o}/app/AddOrUpdateProjectProperty?project=${t}&key=APP_EDITORS&value=${e.join(",")}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return!!a.ok||(console.warn(`updateMembersAccess() => ${a.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=>{n=t,n&&window.Codicent.init({token:n,baseUrl:o})},this.getToken=()=>n,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:a}=await e.json();return a},this.redirectToCheckout=async e=>{const a=await t(this.options.STRIPE_PUBLIC_KEY);if(!a)throw new Error("Stripe failed to load");const o=await this.createCheckoutSession(e),{error:n}=await a.redirectToCheckout({sessionId:o});if(n)throw new Error(n.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 a=await e.json();return a=a.filter((t=>!t.content.includes("#function_result")&&!t.content.includes("#finish_reason_function_call"))),a},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 a=await e.json();return a.forEach((t=>{t.createdAt=new Date(Date.parse(t.createdAt))})),a},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 a={content:`@${this.options.APP_LOG_CODICENT} #debug #${e}\n${t}`,type:"text"},n=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(a)});if(!n.ok)throw new Error(`${n.statusText||"Failed to post log message!"}`);return(await n.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],a=atob(t),o=JSON.parse(a).nickname;if(!await this.addFollower(e,o))throw new Error("Failed to add follower: "+o)}catch(t){console.error("Error extracting adding anonymous follower:",t)}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 this.request(`${o}app/GetForms?codicent=${this.codicent}`,"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.getTodoStatus=async t=>{const e=await fetch(`${o}/app/GetTodoStatus?messageId=${t}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});return e.ok?await e.text():(e.status,console.warn(`getTodoStatus() => ${e.statusText}`),"unknown")},this.updateTodoStatus=async(t,e)=>{const a=await fetch(`${o}/app/UpdateTodoStatus?messageId=${t}&status=${e}`,{method:"GET",headers:[["Authorization",`Bearer ${this.getToken()}`]]});if(!a.ok)return console.warn(`updateTodoStatus() => ${a.statusText}`),!1;return await a.json()},this.codicent="",this.options=a}async request(t,e,a={}){const o={};a.headers&&a.headers.forEach((([t,e])=>{o[t]=e}));const n=await fetch(t,{...a,method:e,headers:o});if(!n.ok)throw 401===n.status&&this.handleUnauthorized(),new Error(`${n.statusText}`);return n}handleUnauthorized(){this.onUnauthorized&&this.onUnauthorized()}}a=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 t=>{fetch(a.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 a=window.URL.createObjectURL(e),o=document.createElement("a");o.style.display="none",o.href=a,o.download=t.filename,document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(a)})).catch((t=>{console.error("There was a problem with the fetch operation:",t)}))},r.getMiniChatReply=async(t,e="codicent-mini",a)=>{const n=await fetch(`${o}app/GetAi2ChatReply?message=${t}&project=${e}${a?"&messageId="+a:""}`,{method:"GET",headers:[["Authorization","Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjJlMTliNjNmLWQxNDgtNGRmMi04MzMxLTZlZGE3ZTQzNjQ1ZCIsIm5pY2tuYW1lIjoiam9oYW4iLCJuYW1lIjoiSm9oYW4gSXNha3Nzb24iLCJ1c2VySWQiOiIyZTE5YjYzZi1kMTQ4LTRkZjItODMzMS02ZWRhN2U0MzY0NWQiLCJwcm9qZWN0IjoiY29kaWNlbnQtbWluaSIsIm5iZiI6MTczNjkzMjcyOCwiZXhwIjoxNzY4NDY4NzI4LCJpYXQiOjE3MzY5MzI3Mjh9.l2J7GgfU01iihdud7QP1aYBCM3NgxxqiM4VrplLO1s0"]]});if(!n.ok)return void n.status;return(await n.json()).content.replace("@codicent-mini","").trim()};export{r as CodicentService};
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,7 @@ declare class CodicentService {
|
|
|
73
73
|
getFileInfo: (fileId: string) => Promise<FileInfo>;
|
|
74
74
|
static getImageUrl: (fileId: string, width: number) => string;
|
|
75
75
|
static getFileUrl: (fileId: string, extension?: string) => string;
|
|
76
|
+
generateApiToken: (expires?: Date, forUserNickname?: string) => Promise<string>;
|
|
76
77
|
sendMessage: (message: string, parentId?: string) => Promise<string>;
|
|
77
78
|
chat: (message: string, messageId?: string) => Promise<ChatMessageReply>;
|
|
78
79
|
/**
|
|
@@ -822,6 +823,11 @@ interface AppConfigOptions {
|
|
|
822
823
|
FORM_BACKGROUND_IMAGE_URL: undefined | string;
|
|
823
824
|
AUTO_TRANSLATE: boolean;
|
|
824
825
|
FORCE_LANGUAGE: string | undefined;
|
|
826
|
+
TRANSLATIONS: {
|
|
827
|
+
[key: string]: {
|
|
828
|
+
[key: string]: string;
|
|
829
|
+
};
|
|
830
|
+
} | undefined;
|
|
825
831
|
APP_LOGBOOK_TITLE: undefined | string;
|
|
826
832
|
LOGIN_WELCOME_TEXT: string | undefined;
|
|
827
833
|
LOGIN_HIDE_WELCOME: boolean;
|