document['addEventListener']('DOMContentLoaded',()=>{const _0x5895ec=document['getElementById']('generateBtn'),_0x303826=document['getElementById']('addTitleBtn'),_0x20448a=document['getElementById']('exampleBtn'),_0xafd2ed=document['getElementById']('clearBtn'),_0x5c8ade=document['getElementById']('downloadBtn'),_0x5add67=document['getElementById']('titlesContainer'),_0x376e06=document['getElementById']('titlesList');function _0x3f455a(){const _0x5ed6a9=document['getElementById']('systemMessage')['value']['trim'](),_0x12b0e4=document['getElementById']('productDescription')['value']['trim'](),_0xea2fb4=document['getElementById']('testProduct')['value']['trim'](),_0x4d9fce=[...document['querySelectorAll']('.example-title')],_0x30174f=_0x4d9fce['length']>0x0&&_0x4d9fce['every'](_0x19031d=>_0x19031d['value']['trim']());_0x5895ec['disabled']=!(_0x5ed6a9&&_0x12b0e4&&_0xea2fb4&&_0x30174f);}document['body']['oninput']=_0x3f455a;function _0x28ee96(_0x3af7d5=''){const _0xa35d02=document['createElement']('div');_0xa35d02['className']='title-row',_0xa35d02['innerHTML']='\x0a\x20\x20\x20\x20\x20\x20<input\x20type=\x22text\x22\x20class=\x22example-title\x22\x20placeholder=\x22Example:\x20Small\x20Quiet\x20Desk\x20Fan\x22\x20value=\x22'+_0x3af7d5+'\x22>\x0a\x20\x20\x20\x20\x20\x20<button\x20class=\x22delete-btn\x22>✖️</button>\x0a\x20\x20\x20\x20',_0xa35d02['querySelector']('.delete-btn')['onclick']=()=>{_0xa35d02['remove'](),_0x3f455a();},_0x5add67['appendChild'](_0xa35d02),_0x3f455a();}_0x303826['onclick']=()=>_0x28ee96(),_0x20448a['onclick']=()=>{document['getElementById']('systemMessage')['value']='Make\x205\x20short\x20titles,\x20easy\x20to\x20read.',document['getElementById']('productDescription')['value']='Small\x20USB\x20fan,\x20quiet,\x20good\x20for\x20desk,\x20has\x203\x20speeds.',_0x5add67['innerHTML']='',['Quiet\x20USB\x20Desk\x20Fan','Small\x20Desk\x20Fan\x20with\x203\x20Speeds']['forEach'](_0x28ee96),document['getElementById']('testProduct')['value']='Portable\x20quiet\x20USB\x20fan\x20for\x20office\x20desk.',_0x3f455a();},_0xafd2ed['onclick']=()=>{['systemMessage','productDescription','testProduct']['forEach'](_0x59adfa=>document['getElementById'](_0x59adfa)['value']=''),_0x5add67['innerHTML']='',_0x28ee96(),_0x376e06['innerHTML']='',_0x3f455a();},_0x5895ec['onclick']=async()=>{_0x5895ec['disabled']=!0x0,_0x376e06['innerHTML']='<li>Please\x20wait...</li>';const _0x6b12ae={'model':'gpt-4o-mini','system_message':document['getElementById']('systemMessage')['value'],'function_schema':{'name':'product_copywriting_data','description':'','parameters':{'type':'object','properties':{'final_titles':{'type':'array','items':{'type':'string'}}},'required':['final_titles']}},'example_user_input':document['getElementById']('productDescription')['value'],'example_assistant_output_arguments':{'final_titles':[...document['querySelectorAll']('.example-title')]['map'](_0x54e9ce=>_0x54e9ce['value'])},'user_input':document['getElementById']('testProduct')['value']};try{const _0x91a857=await fetch('https://openai-function-call-djybcnnsgq-uc.a.run.app',{'method':'POST','headers':{'Content-Type':'application/json'},'body':JSON['stringify'](_0x6b12ae)});var _0x5aa567=await _0x91a857['json']();_0x5aa567&&'object'==typeof _0x5aa567||(_0x5aa567=JSON['parse'](_0x5aa567)),_0x376e06['innerHTML']='',_0x5aa567['final_titles']['forEach'](_0x5cbaab=>{const _0x3da529=document['createElement']('li');_0x3da529['textContent']=_0x5cbaab,_0x376e06['appendChild'](_0x3da529);});}catch{_0x376e06['innerHTML']='<li>Error\x20getting\x20titles.</li>';}finally{_0x5895ec['disabled']=!0x1;}},_0x5c8ade['onclick']=()=>{const _0x19d0aa={'system_message':document['getElementById']('systemMessage')['value'],'example_user_input':document['getElementById']('productDescription')['value'],'example_assistant_output_arguments':{'final_titles':[...document['querySelectorAll']('.example-title')]['map'](_0x1db4e5=>_0x1db4e5['value'])}},_0xed5ae9=new Blob([JSON['stringify'](_0x19d0aa,null,0x2)],{'type':'application/json'}),_0x112eb9=URL['createObjectURL'](_0xed5ae9),_0x371e2f=document['createElement']('a');_0x371e2f['href']=_0x112eb9,_0x371e2f['download']='ai-title-instructions.json',_0x371e2f['click'](),URL['revokeObjectURL'](_0x112eb9);},_0x28ee96(),_0x3f455a();});



