108 );
109
110 // Verify it was deleted by trying to fetch it again
111 const deletedNote = await getNoteById(id);
112 return deletedNote === null;
36});
37
38export default app.fetch;
12 }
13
14 const response = await fetch(TOGETHER_API_URL, {
15 method: 'POST',
16 headers: {
31 };
32
33 const response = await fetch('/api/generate', {
34 method: 'POST',
35 headers: {
50 };
51
52 const response = await fetch('/api/analyze', {
53 method: 'POST',
54 headers: {
52});
53
54export default app.fetch; // This is the entry point for HTTP vals
17
18 useEffect(() => {
19 fetchNote();
20 }, [noteId]);
21
22 const fetchNote = async () => {
23 try {
24 setIsLoading(true);
25 setError('');
26
27 const response = await fetch(`/api/notes/${noteId}`);
28
29 if (!response.ok) {
40 setRequiresPassword(!!data.requiresPassword);
41 } catch (error) {
42 console.error('Error fetching note:', error);
43 setError('Failed to load note');
44 } finally {
55
56 try {
57 const response = await fetch(`/api/notes/${noteId}/verify`, {
58 method: 'POST',
59 headers: { 'Content-Type': 'application/json' },
29 };
30
31 const response = await fetch('/api/notes', {
32 method: 'POST',
33 headers: { 'Content-Type': 'application/json' },
1import { fetch } from "https://esm.town/v/std/fetch";
2import { OpenAI } from "https://esm.town/v/std/openai";
3import { z } from "npm:zod";
1277function hWNext(){if(wNBtn.disabled||isT)return;hideFError();if(cQUI){const iEl=gE(\`q-\${cQUI.fieldKey}\`);if(!iEl){console.error("Input element not found for:",cQUI.fieldKey);return}const ansV=iEl.value;const qDef = cPUI.questions.find(q => q.key === cQUI.fieldKey); if (qDef && !qDef.optional && !ansV.trim()) {rendErr('This input is required.',true,\`The field '\${qDef.displayName || cQUI.text.replace(/\\s*\\(Optional\\)\\s*$/i,"").replace(/[?:]\\s*$/,"")}' is required.\`);if(iEl)iEl.focus();return}wSCEl.innerHTML=\`<div class="lI"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" /></svg>Processing answer...</div>\`;sendQReq({action:'answer',processId:cPUI.id,sessionId:cSId,state:cQSt,lastAnswer:{fieldKey:cQUI.fieldKey,value:ansV}})}else if(wNBtn.textContent.includes('Generate')&&cQSt?.isDone&&finExData){wSCEl.innerHTML=\`<div class="lI"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="animate-spin"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" /></svg>Generating results with AI... This may take a moment.</div>\`;updWNav();sendExReq(finExData)}else if(wNBtn.textContent.includes('Return to List'))showGrid()}
1278function hideFError(){const eEl=gE('wizard-field-error');if(eEl){eEl.textContent='';eEl.style.display='none'}}
1279async function sendQReq(pLd){isT=true;updWNav();try{const rsp=await fetch('/questionnaire',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(pLd)});const d=await rsp.json();cSId=d.sid;cQSt=d.state;if(cQSt?.totalSteps)tQEst=cQSt.totalSteps;if(!rsp.ok||d.err||d.fieldError){if(d.fieldError&&d.nextQ){rendQ(d.nextQ);rendErr(d.err||"Validation Error",true,d.fieldError)}else rendErr(d.err||\`Server Error (\${rsp.status}). Please check console for details.\`)}else if(d.isDone&&d.data){cQUI=null;finExData=d.data;wSCEl.innerHTML='<div class="lI status-message">All questions answered. Click "Generate" to get results.</div>'}else if(d.nextQ)rendQ(d.nextQ);else rendErr("Unexpected response from questionnaire server.")}catch(err){rendErr(\`Communication Error with Questionnaire: \${err.message}\`)}finally{isT=false;updPInd();updWNav()}}
1280async function sendExReq(pLd){isT=true;updWNav();wSCEl.innerHTML=\`<div class="lI"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="animate-spin"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" /></svg>Generating results with AI... This may take a moment.</div>\`;try{const rsp=await fetch('/execute',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(pLd)});const d=await rsp.json();if(!rsp.ok||d.err)throw new Error(d.details || d.err || \`Execution failed on server (Status: \${rsp.status})\`);if (d.res) { rendR(d.res, pLd.processId); } else { throw new Error("Execution succeeded but no results were returned from the server.");}}catch(err){rendErr(\`Execution Error: \${err.message}\`)}finally{isT=false;updPInd();updWNav(true)}}
1281initUI();
1282</script></body></html>`;
87function hWNext(){if(wNBtn.disabled||isT)return;hideFError();if(cQUI){const iEl=gE(\`q-\${cQUI.fieldKey}\`);if(!iEl)return;const ansV=iEl.value;const qDef = cPUI.questions.find(q => q.key === cQUI.fieldKey); if (qDef && !qDef.optional && !ansV.trim()) {rendErr('This input is required.',true,\`The field '\<span class="math-inline">\{qDef\.displayName \|\| cQUI\.text\.replace\(/\\s\*\\\(Optional\\\)\\s\*</span>/i,"").replace(/[?:]\s*$/,"")}' is required.\`);if(iEl)iEl.focus();return}wSCEl.innerHTML=\`<div class="lI"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" /></svg>Processing...</div>\`;sendQReq({action:'answer',processId:cPUI.id,sessionId:cSId,state:cQSt,lastAnswer:{fieldKey:cQUI.fieldKey,value:ansV}})}else if(wNBtn.textContent.includes('Generate')&&cQSt?.isDone&&finExData){wSCEl.innerHTML=\`<div class="lI"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="animate-spin"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" /></svg>Generating (AI)...</div>\`;updWNav();sendExReq(finExData)}else if(wNBtn.textContent.includes('Return'))showGrid()}
88function hideFError(){const eEl=gE('wizard-field-error');if(eEl){eEl.textContent='';eEl.style.display='none'}}
89async function sendQReq(pLd){isT=true;updWNav();try{const rsp=await fetch('/questionnaire',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(pLd)});const d=await rsp.json();cSId=d.sid;cQSt=d.state;if(cQSt?.totalSteps)tQEst=cQSt.totalSteps;if(!rsp.ok||d.err||d.fieldError){if(d.fieldError&&d.nextQ){rendQ(d.nextQ);rendErr(d.err||"Validation Error",true,d.fieldError)}else rendErr(d.err||\`Server Error (\${rsp.status}).\`); console.error("Server Error Detail:", d);}else if(d.isDone&&d.data){cQUI=null;finExData=d.data;wSCEl.innerHTML='<div class="lI status-message">All questions answered. Click "Generate".</div>'}else if(d.nextQ)rendQ(d.nextQ);else rendErr("Unexpected Q server response.")}catch(err){rendErr(\`Communication Error (Q): \${(err instanceof Error ? err.message : String(err))}\`)}finally{isT=false;updPInd();updWNav()}}
90async function sendExReq(pLd){isT=true;updWNav();wSCEl.innerHTML=\`<div class="lI"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="animate-spin"><path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0l3.181 3.183a8.25 8.25 0 0013.803-3.7M4.031 9.865a8.25 8.25 0 0113.803-3.7l3.181 3.182m0-4.991v4.99" /></svg>Generating (AI)...</div>\`;try{const rsp=await fetch('/execute',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify(pLd)});const d=await rsp.json();if(!rsp.ok||d.err)throw new Error(d.details || d.err || \`Execution fail (Status: \${rsp.status})\`);if (d.res) { rendR(d.res, pLd.processId); } else { throw new Error("Execution OK but no results from server.");}}catch(err){rendErr(\`Execution Error: \${(err instanceof Error ? err.message : String(err))}\`)}finally{isT=false;updPInd();updWNav(true)}}
91initUI();
92</script></body></html>`;