PageSourceSearch

https://app.stoqui.com.br/assets/AIDescriptionGenerator-Ds6TWqQ6.js

js stoqui.com.br collected 2026-09-24 11:58:52 UTC 5,043 bytes, 1 lines download raw bytes

1import{j as t,a7 as j,x as V,N as L,T as Y,ab as J,ad as X}from"./mui-CRsYZxVY.js";import{r as a}from"./vendor-Dwao9eNC.js";import{e as Z,r as $,da as i,db as S,cZ as q,X as Q,aK as D}from"./index-TALscxEc.js";import{L as ee,D as te,P as oe,T as se,B as ae,I as ne,a as ie,b as re,M as le,c as de,d as ce,e as fe}from"./LocalizedRichTextEditor-DcQWzYKR.js";import{A as ue,a as pe}from"./AILoadingPlaceholder-FTYHEpKt.js";import{U as me,a as ge}from"./icons-D8aatgQ4.js";import"./query-8ViTdhdk.js";import"./datePickers-BIJXYOKG.js";import"./lab-DSem1Osk.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"2ad85febf9735404429b0670d4acf56a0af5a0a2"}}catch{}})();try{(function(){var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="675d270b-07b4-42d7-b065-1bb25177b693",n._sentryDebugIdIdentifier="sentry-dbid-675d270b-07b4-42d7-b065-1bb25177b693")})()}catch{}function Te({productName:n,currentDescription:e,attributes:P,disabled:w,error:M,helperText:B,onChange:u,suggestedDescription:I=null,isLoadingAISuggestions:R=!1,onUserInput:m}){const[T,A]=a.useState(!1),[C,g]=a.useState(null),[H,h]=a.useState(!1),[E,x]=a.useState(null),[_,k]=a.useState(!1),{data:p}=Z(),{triggerPaywall:G}=$(),d=a.useRef(null),c=a.useRef(e),f=I!==null&&e!==null&&e!==""&&i(e||"")===i(I),b=a.useRef(!1);a.useEffect(()=>{f&&(b.current=!1)},[f]),a.useEffect(()=>{var s;const o=(s=d.current)==null?void 0:s.editor;if(o&&e!==c.current){const r=o.getHTML(),l=i(e&&!/<[a-z][\s\S]*>/i.test(e)?S(e):e||"");l!==i(r)&&o.commands.setContent(l),c.current=e}},[e]);const v=()=>(p!=null&&p.gives_access&&p.plan||"free")==="lite"?"pro":"lite",F=async()=>{var o;A(!0),g(null);try{const s=localStorage.getItem("supabase.auth.token");try{const l=await(await D("products/generate-description",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},data:JSON.stringify({productName:n,currentDescription:e,attributes:P})})).data;x(e||"");const y=(o=d.current)==null?void 0:o.editor;if(y){const N=i(l.description&&!/<[a-z][\s\S]*>/i.test(l.description)?S(l.description):l.description||"");y.commands.setContent(N);const z=i(y.getHTML());c.current=z,u(z)}h(!0)}catch(r){if(r.response&&r.response.status===429){G("ai_descriptions_limit",{pageAction:()=>k(!0),source:"product_form"});return}throw r}}catch(s){console.error("Error generating description:",s),g(s.message||"Error generating description")}finally{A(!1)}},O=()=>{h(!1),x(null)},U=()=>{var s;const o=(s=d.current)==null?void 0:s.editor;if(o&&E!==null){o.commands.setContent(i(E));const r=i(o.getHTML());c.current=r,u(r)}h(!1),x(null)},W=a.useCallback(()=>{var o;if(f&&!b.current){const s=(o=d.current)==null?void 0:o.editor;s&&(b.current=!0,s.commands.selectAll())}},[f]),K=a.useCallback(({editor:o})=>{const s=i(o.getHTML());c.current=s,u(s),m&&m()},[u,m]);return t.jsxs(j,{children:[t.jsx(V,{shrink:!0,htmlFor:"product-description-editor",sx:{fontWeight:600,color:"text.secondary",ml:1.5},children:"Descrição"}),t.jsx(ue,{active:f,children:t.jsxs(j,{sx:{position:"relative"},children:[t.jsx(ee,{ref:d,sx:{backgroundColor:"white","& .ProseMirror":{fontSize:"14px !important",fontWeight:"500 !important",minHeight:"200px",maxHeight:"400px","& strong":{fontWeight:"800 !important"},overflowY:"auto",padding:"8px","&:focus":{outline:"none",fontSize:"14px !important",fontWeight:"500 !important"}}},extensions:[te,oe,se,ae,ne,ie,re],content:i(e&&!/<[a-z][\s\S]*>/i.test(e)?S(e):e||""),onUpdate:K,onFocus:W,renderControls:o=>t.jsxs(le,{children:[t.jsx(de,{tooltipLabel:o("bold")}),t.jsx(ce,{tooltipLabel:o("italic")}),t.jsx(fe,{tooltipLabel:o("bulletList")}),t.jsx(L,{variant:"text",color:"primary",size:"small",startIcon:t.jsx(q,{}),onClick:F,disabled:T||w||!n,sx:{ml:"auto"},children:T?"Gerando...":"Gerar com I.A."})]}),editable:!w}),t.jsx(pe,{show:R&&!e,text:"✨ Gerando descrição...",variant:"editor"})]})}),M&&t.jsx(Y,{variant:"caption",color:"error",sx:{mt:1,display:"block"},children:B}),t.jsx(j,{sx:{mt:.5,display:"flex",justifyContent:"flex-end"},children:H&&t.jsxs(J,{direction:"row",spacing:1,children:[t.jsx(L,{size:"small",onClick:U,variant:"text",color:"inherit",startIcon:t.jsx(me,{}),children:"Desfazer"}),t.jsx(L,{size:"small",onClick:O,variant:"contained",endIcon:t.jsx(ge,{}),children:"Usar descrição"})]})}),C&&t.jsx(X,{severity:"error",onClose:()=>g(null),sx:{mt:1},children:C}),t.jsx(Q,{open:_,onClose:()=>k(!1),title:"Limite de descrições com I.A.",description:v()==="pro"?"Você atingiu o limite mensal de descrições com I.A. do plano Lite. Faça upgrade para o plano Pro para ter descrições ilimitadas.":"Você atingiu o limite de descrições com I.A. do plano Grátis. Assine o plano Lite para ter mais descrições ou o plano Pro para ter descrições ilimitadas.",planSuggestion:v()})]})}export{Te as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.