wizards 0.2.8 → 0.2.10

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.
Files changed (60) hide show
  1. package/apps/runtime/dist/agents/project-assistant.js +16 -2
  2. package/apps/runtime/dist/agents/website.js +48 -10
  3. package/apps/runtime/dist/app.js +2 -0
  4. package/apps/runtime/dist/db/control-schema.js +18 -1
  5. package/apps/runtime/dist/db/migrations/control/0007_common_the_hand.sql +15 -0
  6. package/apps/runtime/dist/db/migrations/control/meta/0007_snapshot.json +460 -0
  7. package/apps/runtime/dist/db/migrations/control/meta/_journal.json +7 -0
  8. package/apps/runtime/dist/db/migrations/tenant/0006_hard_war_machine.sql +30 -0
  9. package/apps/runtime/dist/db/migrations/tenant/meta/0006_snapshot.json +1696 -0
  10. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
  11. package/apps/runtime/dist/db/schema.js +12 -6
  12. package/apps/runtime/dist/engine/steps.js +3 -0
  13. package/apps/runtime/dist/env.js +2 -0
  14. package/apps/runtime/dist/index.js +2 -0
  15. package/apps/runtime/dist/plugins/events.js +37 -14
  16. package/apps/runtime/dist/plugins/jobs.js +64 -0
  17. package/apps/runtime/dist/plugins/loader.js +67 -4
  18. package/apps/runtime/dist/plugins/public.js +31 -0
  19. package/apps/runtime/dist/plugins/registry.js +5 -0
  20. package/apps/runtime/dist/routes/plugin-public.js +59 -0
  21. package/apps/runtime/dist/routes/plugins.js +1 -1
  22. package/apps/runtime/dist/routes/studio.js +3 -0
  23. package/apps/runtime/dist/services/project-files.js +4 -0
  24. package/apps/runtime/dist/services/project-index.js +69 -9
  25. package/apps/runtime/dist/services/projects.js +7 -1
  26. package/apps/runtime/dist/services/spaces.js +2 -0
  27. package/apps/runtime/dist/tools/index.js +3 -2
  28. package/apps/runtime/dist/tools/plugin.js +89 -17
  29. package/apps/runtime/dist/tools/project.js +39 -31
  30. package/apps/web/dist/assets/Account-6cwwWOU3.js +1 -0
  31. package/apps/web/dist/assets/{ChangelogDialog-BNQ9yup8.js → ChangelogDialog-DewAXwoQ.js} +1 -1
  32. package/apps/web/dist/assets/{ChatPanel-CtE1wcUD.js → ChatPanel-CCNgem_v.js} +1 -1
  33. package/apps/web/dist/assets/{EditorPage-CAxamSak.js → EditorPage-DqVuS-JG.js} +2 -2
  34. package/apps/web/dist/assets/{FlowPreview-B3IxmikV.js → FlowPreview-BAVCgsXg.js} +1 -1
  35. package/apps/web/dist/assets/{Harness-Bo-kwm1H.js → Harness-BZCoZ4Z1.js} +1 -1
  36. package/apps/web/dist/assets/{HomePage-BdIa2zcg.js → HomePage-BsuuOXbB.js} +1 -1
  37. package/apps/web/dist/assets/{ImportWizard-DMea5ZH1.js → ImportWizard-BG28_HzC.js} +1 -1
  38. package/apps/web/dist/assets/{LocalRuntime-DFswQjxc.js → LocalRuntime-DyJJVozN.js} +1 -1
  39. package/apps/web/dist/assets/{NewWizardPage-Cnb6UYme.js → NewWizardPage-8B-d3T4k.js} +2 -2
  40. package/apps/web/dist/assets/ProjectPage-CkO8ndix.js +2 -0
  41. package/apps/web/dist/assets/{PublicRunner-CIHEMLlN.js → PublicRunner-DF960weZ.js} +1 -1
  42. package/apps/web/dist/assets/{RunnerView-COKGppwq.js → RunnerView-Z3VVOwVR.js} +1 -1
  43. package/apps/web/dist/assets/SettingsPage-BOYAZS08.js +1 -0
  44. package/apps/web/dist/assets/{SetupPage-Bk4qXYZV.js → SetupPage-Cl4Yc7A2.js} +1 -1
  45. package/apps/web/dist/assets/{SharePage-ChEtCkhn.js → SharePage-BFRWRmOF.js} +1 -1
  46. package/apps/web/dist/assets/changelog-DhleQ4p1.js +1 -0
  47. package/apps/web/dist/assets/{esm-Rtjq9ReB.js → esm-CLbOcpCO.js} +1 -1
  48. package/apps/web/dist/assets/index-Bl5vhqT3.js +10 -0
  49. package/apps/web/dist/assets/{meta-MVWkLr9H.js → meta-DxGh33r8.js} +1 -1
  50. package/apps/web/dist/assets/{outputs-s8BpXH6V.js → outputs-BDP8UsZT.js} +1 -1
  51. package/apps/web/dist/index.html +1 -1
  52. package/node_modules/@engenty-wizards/plugin-sdk/dist/index.d.ts +183 -0
  53. package/node_modules/@engenty-wizards/plugin-sdk/dist/studio.d.ts +48 -3
  54. package/node_modules/@engenty-wizards/shared/dist/projects.d.ts +7 -1
  55. package/package.json +1 -1
  56. package/apps/web/dist/assets/Account-YJEQEo5k.js +0 -1
  57. package/apps/web/dist/assets/ProjectPage-CR_FIUya.js +0 -2
  58. package/apps/web/dist/assets/SettingsPage-BqAogRSI.js +0 -1
  59. package/apps/web/dist/assets/changelog-C03GWYid.js +0 -1
  60. package/apps/web/dist/assets/index-BAQ2e4is.js +0 -10
@@ -1 +1 @@
1
- import{t as e}from"./createLucideIcon-q3MZMmnf.js";import{n as t,t as n}from"./wand-sparkles-Clj3VRB5.js";import{n as r}from"./mic-Bvz4mA2j.js";import{t as i}from"./image-BShbErBm.js";import{t as a}from"./video-DBmwF1Jm.js";import{y as o}from"./ui-gGAdXx-P.js";import{N as s}from"./index-BAQ2e4is.js";var c={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};c.node;var l=e(c),u={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};u.node;var d=e(u),f={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};f.node;var p=e(f),m={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};m.node;var h=e(m);function g(e){switch(e.type){case`page`:return h;case`agent`:return l;case`generate`:return e.asset===`image`?i:e.asset===`video`?a:e.asset===`dashboard`?p:r;case`widget`:return s;case`review`:return t;case`result`:return d}return n}var _={page:`bg-cobalt-tint text-cobalt`,agent:`bg-ember-tint text-ember-strong`,generate:`bg-amber-tint text-ink-2`,widget:`bg-ember-veil text-ember-strong`,review:`bg-moss-tint text-moss`,result:`bg-paper-2 text-ink-2`};function v(e){return o(`type.${e.type}`)}var y=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`];function b(e){return y.includes(e)?o(`tool.${e}`):e}function x(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(b),n=e.mcp?.length?[`MCP: ${e.mcp.join(`, `)}`]:[];return[...t,...n].join(` · `)||e.instructions.slice(0,90)}case`generate`:{let t=[e.asset];return e.options?.aspectRatio&&t.push(e.options.aspectRatio),e.options?.duration&&t.push(`${e.options.duration}s`),e.options?.resolution&&t.push(e.options.resolution),e.options?.template&&t.push(e.options.template),t.join(` · `)}case`widget`:return[e.entry,Object.keys(e.data).join(`, `)].filter(Boolean).join(` · `);case`review`:return[e.edit?o(`editor.reviewEditable`):null,e.regenerate?o(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}export{v as a,l as c,b as i,g as n,h as o,x as r,d as s,_ as t};
1
+ import{t as e}from"./createLucideIcon-q3MZMmnf.js";import{n as t,t as n}from"./wand-sparkles-Clj3VRB5.js";import{n as r}from"./mic-Bvz4mA2j.js";import{t as i}from"./image-BShbErBm.js";import{t as a}from"./video-DBmwF1Jm.js";import{y as o}from"./ui-gGAdXx-P.js";import{P as s}from"./index-Bl5vhqT3.js";var c={name:`bot`,size:24,node:[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]};c.node;var l=e(c),u={name:`flag`,size:24,node:[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]};u.node;var d=e(u),f={name:`layout-dashboard`,size:24,node:[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]};f.node;var p=e(f),m={name:`list-checks`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]};m.node;var h=e(m);function g(e){switch(e.type){case`page`:return h;case`agent`:return l;case`generate`:return e.asset===`image`?i:e.asset===`video`?a:e.asset===`dashboard`?p:r;case`widget`:return s;case`review`:return t;case`result`:return d}return n}var _={page:`bg-cobalt-tint text-cobalt`,agent:`bg-ember-tint text-ember-strong`,generate:`bg-amber-tint text-ink-2`,widget:`bg-ember-veil text-ember-strong`,review:`bg-moss-tint text-moss`,result:`bg-paper-2 text-ink-2`};function v(e){return o(`type.${e.type}`)}var y=[`web_search`,`web_fetch`,`browser`,`sandbox`,`image`,`http`];function b(e){return y.includes(e)?o(`tool.${e}`):e}function x(e){switch(e.type){case`page`:return e.fields.map(e=>e.label).join(` · `);case`agent`:{let t=e.tools.map(b),n=e.mcp?.length?[`MCP: ${e.mcp.join(`, `)}`]:[];return[...t,...n].join(` · `)||e.instructions.slice(0,90)}case`generate`:{let t=[e.asset];return e.options?.aspectRatio&&t.push(e.options.aspectRatio),e.options?.duration&&t.push(`${e.options.duration}s`),e.options?.resolution&&t.push(e.options.resolution),e.options?.template&&t.push(e.options.template),t.join(` · `)}case`widget`:return[e.entry,Object.keys(e.data).join(`, `)].filter(Boolean).join(` · `);case`review`:return[e.edit?o(`editor.reviewEditable`):null,e.regenerate?o(`editor.reviewRedo`):null].filter(Boolean).join(` · `);case`result`:return e.deliverables.map(e=>`${e.label??e.from} (${e.formats.join(`, `)})`).join(` · `)}return``}export{v as a,l as c,b as i,g as n,h as o,x as r,d as s,_ as t};
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r,c as i,s as a}from"./api-u3nydnnp.js";import{t as o}from"./createLucideIcon-q3MZMmnf.js";import{t as s}from"./check-CUpby_J9.js";import{n as c}from"./plus-Du-Jx8aI.js";import{n as l}from"./mic-Bvz4mA2j.js";import{d as u,h as d,m as f,y as p}from"./ui-gGAdXx-P.js";import{k as m}from"./index-BAQ2e4is.js";var ee={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};ee.node;var te=o(ee),ne={name:`film`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]};ne.node;var re=o(ne),ie={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};ie.node;var ae=o(ie),h={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};h.node;var oe=o(h),se={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};se.node;var ce=o(se),g={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};g.node;var le=o(g),ue={name:`share`,size:24,node:[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]};ue.node;var de=o(ue),fe={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};fe.node;var pe=o(fe),me={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};me.node;var he=o(me),_=e(t(),1);function ge(){if(typeof window>`u`)return null;let e=window.engentyApp;return e&&typeof e.call==`function`&&Array.isArray(e.can)?e:null}var _e=ge(),ve=_e!==null||typeof window<`u`&&new URLSearchParams(window.location.search).get(`app`)===`1`;ve&&typeof document<`u`&&document.documentElement.classList.add(`in-app`);var v=e=>_e?.can.includes(e)===!0;function ye(e,t){return _e&&v(e)?_e.call(e,t):Promise.reject(Error(`the app cannot ${e}`))}function be(e,t){v(e)&&ye(e,t).catch(()=>void 0)}function y(e,t,n){return v(`download`)?(e.preventDefault(),ye(`download`,{url:new URL(t,window.location.href).href,filename:n}).catch(()=>void 0),!0):!1}var xe=e=>`engenty-wizards://w?url=${encodeURIComponent(e)}`,Se=typeof window<`u`&&window.matchMedia?.(`(pointer: coarse)`).matches===!0,Ce=typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia;function we(){(0,_.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=document.documentElement,n=()=>{let n=e.scale>1.01?0:window.innerHeight-e.height-e.offsetTop,r=n>80;t.style.setProperty(`--kb`,r?`${Math.round(n)}px`:`0px`),t.classList.toggle(`keyboard-open`,r)};return n(),e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),()=>{e.removeEventListener(`resize`,n),e.removeEventListener(`scroll`,n),t.style.removeProperty(`--kb`),t.classList.remove(`keyboard-open`)}},[])}function Te(e){let[t,n]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{if(e&&v(`keepAwake`))return be(`keepAwake`,!0),n(!0),()=>{be(`keepAwake`,!1),n(!1)};if(!e||!(`wakeLock`in navigator))return;let t=null,r=!1,i=async()=>{if(!(r||t||document.visibilityState!==`visible`))try{let e=await navigator.wakeLock.request(`screen`);if(r){e.release().catch(()=>void 0);return}t=e,n(!0),e.addEventListener(`release`,()=>{t===e&&(t=null,n(!1))})}catch{}};return i(),document.addEventListener(`visibilitychange`,i),()=>{r=!0,document.removeEventListener(`visibilitychange`,i),t?.release().catch(()=>void 0),t=null,n(!1)}},[e]),t}var Ee=`wz.notify`,De=new Set,Oe=null;function ke(){try{return localStorage.getItem(Ee)===`1`}catch{return!1}}function b(e){try{e?localStorage.setItem(Ee,`1`):localStorage.removeItem(Ee)}catch{}for(let e of De)e()}var x=typeof window<`u`&&`Notification`in window,S=null;function Ae(){return ke()?v(`notify`)?S===!1?`quiet`:`on`:x&&Notification.permission===`granted`?`on`:`quiet`:`off`}function C(){return(0,_.useSyncExternalStore)(e=>(De.add(e),()=>De.delete(e)),Ae,()=>`off`)}function je(){return v(`notify`)?S===!1:x&&Notification.permission===`denied`}async function Me(){if(b(!0),v(`notify`)){S=!v(`notifyPermission`)||await ye(`notifyPermission`).catch(()=>!1);for(let e of De)e();return Ae()}try{Oe??=new AudioContext,Oe.resume()}catch{Oe=null}if(x&&Notification.permission==="default")try{await Notification.requestPermission()}catch{}x&&Notification.permission===`granted`&&await navigator.serviceWorker?.register(`${r}/sw.js`).catch(()=>void 0);for(let e of De)e();return Ae()}function w(){b(!1)}function Ne(){let e=Oe;if(e?.state!==`running`)return;let t=e.currentTime;for(let[n,r]of[660,880].entries()){let i=e.createOscillator(),a=e.createGain();i.frequency.value=r,a.gain.setValueAtTime(0,t+n*.16),a.gain.linearRampToValueAtTime(.18,t+n*.16+.02),a.gain.exponentialRampToValueAtTime(.001,t+n*.16+.32),i.connect(a).connect(e.destination),i.start(t+n*.16),i.stop(t+n*.16+.34)}}async function Pe(e){if(!ke())return;if(v(`notify`)){be(`notify`,e);return}if(document.visibilityState===`visible`){Ne(),navigator.vibrate?.([120,60,120]);return}if(!x||Notification.permission!==`granted`)return;let t={body:e.body,tag:e.tag,icon:a(`icons/icon-192.png`),badge:a(`icons/icon-192.png`),data:{url:location.href}};try{let n=await navigator.serviceWorker?.getRegistration();if(n?.active){await n.showNotification(e.title,t);return}}catch{}try{new Notification(e.title,t)}catch{}}function Fe(){if(typeof navigator>`u`||!navigator.canShare)return!1;try{return navigator.canShare({files:[new File([`x`],`x.pdf`,{type:`application/pdf`})]})}catch{return!1}}function Ie(e,t){this.v=e,this.k=t}function T(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function E(e){if(Array.isArray(e))return e}function Le(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Re(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{a as r,c as i,s as a}from"./api-u3nydnnp.js";import{t as o}from"./createLucideIcon-q3MZMmnf.js";import{t as s}from"./check-CUpby_J9.js";import{n as c}from"./plus-Du-Jx8aI.js";import{n as l}from"./mic-Bvz4mA2j.js";import{d as u,h as d,m as f,y as p}from"./ui-gGAdXx-P.js";import{A as m}from"./index-Bl5vhqT3.js";var ee={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};ee.node;var te=o(ee),ne={name:`film`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M3 7.5h4`,key:`zfgn84`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}],[`path`,{d:`M3 16.5h4`,key:`1230mu`}],[`path`,{d:`M17 3v18`,key:`in4fa5`}],[`path`,{d:`M17 7.5h4`,key:`myr1c1`}],[`path`,{d:`M17 16.5h4`,key:`go4c1d`}]]};ne.node;var re=o(ne),ie={name:`mail`,size:24,node:[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]};ie.node;var ae=o(ie),h={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};h.node;var oe=o(h),se={name:`paperclip`,size:24,node:[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]};se.node;var ce=o(se),g={name:`pencil`,size:24,node:[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]};g.node;var le=o(g),ue={name:`share`,size:24,node:[[`path`,{d:`M12 2v13`,key:`1km8f5`}],[`path`,{d:`m16 6-4-4-4 4`,key:`13yo43`}],[`path`,{d:`M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8`,key:`1b2hhj`}]]};ue.node;var de=o(ue),fe={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};fe.node;var pe=o(fe),me={name:`square`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]};me.node;var he=o(me),_=e(t(),1);function ge(){if(typeof window>`u`)return null;let e=window.engentyApp;return e&&typeof e.call==`function`&&Array.isArray(e.can)?e:null}var _e=ge(),ve=_e!==null||typeof window<`u`&&new URLSearchParams(window.location.search).get(`app`)===`1`;ve&&typeof document<`u`&&document.documentElement.classList.add(`in-app`);var v=e=>_e?.can.includes(e)===!0;function ye(e,t){return _e&&v(e)?_e.call(e,t):Promise.reject(Error(`the app cannot ${e}`))}function be(e,t){v(e)&&ye(e,t).catch(()=>void 0)}function y(e,t,n){return v(`download`)?(e.preventDefault(),ye(`download`,{url:new URL(t,window.location.href).href,filename:n}).catch(()=>void 0),!0):!1}var xe=e=>`engenty-wizards://w?url=${encodeURIComponent(e)}`,Se=typeof window<`u`&&window.matchMedia?.(`(pointer: coarse)`).matches===!0,Ce=typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia;function we(){(0,_.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=document.documentElement,n=()=>{let n=e.scale>1.01?0:window.innerHeight-e.height-e.offsetTop,r=n>80;t.style.setProperty(`--kb`,r?`${Math.round(n)}px`:`0px`),t.classList.toggle(`keyboard-open`,r)};return n(),e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),()=>{e.removeEventListener(`resize`,n),e.removeEventListener(`scroll`,n),t.style.removeProperty(`--kb`),t.classList.remove(`keyboard-open`)}},[])}function Te(e){let[t,n]=(0,_.useState)(!1);return(0,_.useEffect)(()=>{if(e&&v(`keepAwake`))return be(`keepAwake`,!0),n(!0),()=>{be(`keepAwake`,!1),n(!1)};if(!e||!(`wakeLock`in navigator))return;let t=null,r=!1,i=async()=>{if(!(r||t||document.visibilityState!==`visible`))try{let e=await navigator.wakeLock.request(`screen`);if(r){e.release().catch(()=>void 0);return}t=e,n(!0),e.addEventListener(`release`,()=>{t===e&&(t=null,n(!1))})}catch{}};return i(),document.addEventListener(`visibilitychange`,i),()=>{r=!0,document.removeEventListener(`visibilitychange`,i),t?.release().catch(()=>void 0),t=null,n(!1)}},[e]),t}var Ee=`wz.notify`,De=new Set,Oe=null;function ke(){try{return localStorage.getItem(Ee)===`1`}catch{return!1}}function b(e){try{e?localStorage.setItem(Ee,`1`):localStorage.removeItem(Ee)}catch{}for(let e of De)e()}var x=typeof window<`u`&&`Notification`in window,S=null;function Ae(){return ke()?v(`notify`)?S===!1?`quiet`:`on`:x&&Notification.permission===`granted`?`on`:`quiet`:`off`}function C(){return(0,_.useSyncExternalStore)(e=>(De.add(e),()=>De.delete(e)),Ae,()=>`off`)}function je(){return v(`notify`)?S===!1:x&&Notification.permission===`denied`}async function Me(){if(b(!0),v(`notify`)){S=!v(`notifyPermission`)||await ye(`notifyPermission`).catch(()=>!1);for(let e of De)e();return Ae()}try{Oe??=new AudioContext,Oe.resume()}catch{Oe=null}if(x&&Notification.permission==="default")try{await Notification.requestPermission()}catch{}x&&Notification.permission===`granted`&&await navigator.serviceWorker?.register(`${r}/sw.js`).catch(()=>void 0);for(let e of De)e();return Ae()}function w(){b(!1)}function Ne(){let e=Oe;if(e?.state!==`running`)return;let t=e.currentTime;for(let[n,r]of[660,880].entries()){let i=e.createOscillator(),a=e.createGain();i.frequency.value=r,a.gain.setValueAtTime(0,t+n*.16),a.gain.linearRampToValueAtTime(.18,t+n*.16+.02),a.gain.exponentialRampToValueAtTime(.001,t+n*.16+.32),i.connect(a).connect(e.destination),i.start(t+n*.16),i.stop(t+n*.16+.34)}}async function Pe(e){if(!ke())return;if(v(`notify`)){be(`notify`,e);return}if(document.visibilityState===`visible`){Ne(),navigator.vibrate?.([120,60,120]);return}if(!x||Notification.permission!==`granted`)return;let t={body:e.body,tag:e.tag,icon:a(`icons/icon-192.png`),badge:a(`icons/icon-192.png`),data:{url:location.href}};try{let n=await navigator.serviceWorker?.getRegistration();if(n?.active){await n.showNotification(e.title,t);return}}catch{}try{new Notification(e.title,t)}catch{}}function Fe(){if(typeof navigator>`u`||!navigator.canShare)return!1;try{return navigator.canShare({files:[new File([`x`],`x.pdf`,{type:`application/pdf`})]})}catch{return!1}}function Ie(e,t){this.v=e,this.k=t}function T(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function E(e){if(Array.isArray(e))return e}function Le(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Re(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ze(e,t){return E(e)||Le(e,t)||Be(e,t)||Re()}function Be(e,t){if(e){if(typeof e==`string`)return T(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?T(e,t):void 0}}function Ve(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof Ie;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}Ve.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},Ve.prototype.next=function(e){return this._invoke(`next`,e)},Ve.prototype.throw=function(e){return this._invoke(`throw`,e)},Ve.prototype.return=function(e){return this._invoke(`return`,e)};var He=Object.entries,Ue=Object.setPrototypeOf,We=Object.isFrozen,Ge=Object.getPrototypeOf,Ke=Object.getOwnPropertyDescriptor,D=Object.freeze,O=Object.seal,qe=Object.create,Je=typeof Reflect<`u`&&Reflect,Ye=Je.apply,Xe=Je.construct;D||=function(e){return e},O||=function(e){return e},Ye||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Xe||=function(e){return new e(...[...arguments].slice(1))};var Ze=j(Array.prototype.forEach);Array.prototype.indexOf;var Qe=j(Array.prototype.lastIndexOf),$e=j(Array.prototype.pop),et=j(Array.prototype.push);Array.prototype.slice;var tt=j(Array.prototype.splice),nt=Array.isArray,rt=j(String.prototype.toLowerCase),it=j(String.prototype.toString),at=j(String.prototype.match),ot=j(String.prototype.replace),st=j(String.prototype.indexOf),ct=j(String.prototype.trim),lt=j(Number.prototype.toString),ut=j(Boolean.prototype.toString),dt=typeof BigInt>`u`?null:j(BigInt.prototype.toString),ft=typeof Symbol>`u`?null:j(Symbol.prototype.toString),k=j(Object.prototype.hasOwnProperty),pt=j(Object.prototype.toString),A=j(RegExp.prototype.test),mt=ht(TypeError);function j(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return Ye(e,t,n)}}function ht(e){return function(){return Xe(e,[...arguments])}}function M(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:rt;if(Ue&&Ue(e,null),!nt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(We(t)||(t[r]=e),i=e)}e[i]=!0}return e}function gt(e){for(let t=0;t<e.length;t++)k(e,t)||(e[t]=null);return e}function N(e){let t=qe(null);for(let r of He(e)){var n=ze(r,2);let i=n[0],a=n[1];k(e,i)&&(t[i]=nt(a)?gt(a):a&&typeof a==`object`&&a.constructor===Object?N(a):a)}return t}function _t(e){switch(typeof e){case`string`:return e;case`number`:return lt(e);case`boolean`:return ut(e);case`bigint`:return dt?dt(e):`0`;case`symbol`:return ft?ft(e):`Symbol()`;case`undefined`:return pt(e);case`function`:case`object`:{if(e===null)return pt(e);let t=e,n=P(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:pt(e)}return pt(e)}default:return pt(e)}}function P(e,t){for(;e!==null;){let n=Ke(e,t);if(n){if(n.get)return j(n.get);if(typeof n.value==`function`)return j(n.value)}e=Ge(e)}function n(){return null}return n}function vt(e){try{return A(e,``),!0}catch{return!1}}var yt=D(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),bt=D(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),xt=D([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),St=D([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Ct=D(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),wt=D([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Tt=D([`#text`]),Et=D(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Dt=D(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Ot=D(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),kt=D([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),At=O(/{{[\w\W]*|^[\w\W]*}}/g),jt=O(/<%[\w\W]*|^[\w\W]*%>/g),Mt=O(/\${[\w\W]*/g),Nt=O(/^data-[\-\w.\u00B7-\uFFFF]+$/),Pt=O(/^aria-[\-\w]+$/),Ft=O(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),It=O(/^(?:\w+script|data):/i),Lt=O(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Rt=O(/^html$/i),zt=O(/^[a-z][.\w]*(-[.\w]+)+$/i),Bt=O(/<[/\w!]/g),Vt=O(/<[/\w]/g),Ht=O(/<\/no(script|embed|frames)/i),Ut=O(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Wt=[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`],Gt=D(M({},Wt)),Kt=function(){let e={};return Ze(Wt,t=>{e[t]=O(RegExp(`</`+t+`(?=[\\t\\n\\f\\r />])`,`i`))}),D(e)}(),qt=function(){return typeof window>`u`?null:window},Jt=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Yt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},I=function(e,t,n,r){return k(e,t)&&nt(e[t])?M(r.base?N(r.base):{},e[t],r.transform):n},Xt=function(e,t,n){let r=k(e,t)?e[t]:void 0;return r&&typeof r==`object`?N(r):n()};function Zt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qt(),t=e=>Zt(e);if(t.version=`3.4.16`,t.removed=[],!e||!e.document||e.document.nodeType!==F.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=P(d,`cloneNode`),p=P(d,`remove`),m=P(d,`removeAttributeNode`),ee=P(d,`nextSibling`),te=P(d,`childNodes`),ne=P(d,`parentNode`),re=P(d,`shadowRoot`),ie=P(d,`attributes`),ae=o&&o.prototype?P(o.prototype,`nodeType`):null,h=o&&o.prototype?P(o.prototype,`nodeName`):null,oe=o&&o.prototype?P(o.prototype,`ownerDocument`):null,se=function(e){return ae?ae(e):e.nodeType},ce=function(e){return h?h(e):e.nodeName};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let g,le=``,ue,de=!1,fe=0,pe=function(){if(fe>0)throw mt(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},me=function(e){pe(),fe++;try{return g.createHTML(e)}finally{fe--}},he=function(e){pe(),fe++;try{return g.createScriptURL(e)}finally{fe--}},_=function(){return de||=(ue=Jt(u,i),!0),ue},ge=n,_e=ge.implementation,ve=ge.createNodeIterator,v=ge.createDocumentFragment,ye=ge.getElementsByTagName,be=r.importNode,y=Yt();t.isSupported=typeof He==`function`&&typeof ne==`function`&&_e&&_e.createHTMLDocument!==void 0;let xe=At,Se=jt,Ce=Mt,we=Nt,Te=Pt,Ee=It,De=Lt,Oe=zt,ke=Ft,b=null,x=M({},[...yt,...bt,...xt,...Ct,...Tt]),S=null,Ae=M({},[...Et,...Dt,...Ot,...kt]),C=Object.seal(qe(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),je=null,Me=null,w=Object.seal(qe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ne=!0,Pe=!0,Fe=!1,Ie=!0,T=!1,E=!0,Le=!1,Re=!1,ze=null,Be=null,Ve=!1,Ue=!1,We=!1,Ge=!1,Ke=!0,Je=!1,Ye=`user-content-`,Xe=!0,lt=!1,ut={},dt=null,ft=M({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),pt=null,j=M({},[`audio`,`video`,`img`,`source`,`image`,`track`]),ht=null,gt=M({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Wt=`http://www.w3.org/1998/Math/MathML`,Qt=`http://www.w3.org/2000/svg`,L=`http://www.w3.org/1999/xhtml`,R=L,$t=!1,z=null,en=M({},[Wt,Qt,L],it),B=D([`mi`,`mo`,`mn`,`ms`,`mtext`]),tn=M({},B),V=D([`annotation-xml`]),nn=M({},V),rn=M({},[`title`,`style`,`font`,`a`,`script`]),an=null,on=[`application/xhtml+xml`,`text/html`],H=null,U=null,sn=n.createElement(`form`),cn=function(e){return e instanceof RegExp||e instanceof Function},ln=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(U&&U===e)return;(!e||typeof e!=`object`)&&(e={}),e=N(e),an=on.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,H=an===`application/xhtml+xml`?it:rt,b=I(e,`ALLOWED_TAGS`,x,{transform:H}),S=I(e,`ALLOWED_ATTR`,Ae,{transform:H}),z=I(e,`ALLOWED_NAMESPACES`,en,{transform:it}),ht=I(e,`ADD_URI_SAFE_ATTR`,gt,{transform:H,base:gt}),pt=I(e,`ADD_DATA_URI_TAGS`,j,{transform:H,base:j}),dt=I(e,`FORBID_CONTENTS`,ft,{transform:H}),je=I(e,`FORBID_TAGS`,N({}),{transform:H}),Me=I(e,`FORBID_ATTR`,N({}),{transform:H}),ut=k(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?N(e.USE_PROFILES):e.USE_PROFILES:!1,Ne=e.ALLOW_ARIA_ATTR!==!1,Pe=e.ALLOW_DATA_ATTR!==!1,Fe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ie=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,T=e.SAFE_FOR_TEMPLATES||!1,E=e.SAFE_FOR_XML!==!1,Le=e.WHOLE_DOCUMENT||!1,Ue=e.RETURN_DOM||!1,We=e.RETURN_DOM_FRAGMENT||!1,Ge=e.RETURN_TRUSTED_TYPE||!1,Ve=e.FORCE_BODY||!1,Ke=e.SANITIZE_DOM!==!1,Je=e.SANITIZE_NAMED_PROPS||!1,Xe=e.KEEP_CONTENT!==!1,lt=e.IN_PLACE||!1,ke=vt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Ft,R=typeof e.NAMESPACE==`string`?e.NAMESPACE:L,tn=Xt(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>M({},B)),nn=Xt(e,`HTML_INTEGRATION_POINTS`,()=>M({},V));let t=Xt(e,`CUSTOM_ELEMENT_HANDLING`,()=>qe(null));if(C=qe(null),k(t,`tagNameCheck`)&&cn(t.tagNameCheck)&&(C.tagNameCheck=t.tagNameCheck),k(t,`attributeNameCheck`)&&cn(t.attributeNameCheck)&&(C.attributeNameCheck=t.attributeNameCheck),k(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(C.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),O(C),T&&(Pe=!1),We&&(Ue=!0),ut&&(b=M({},Tt),S=qe(null),ut.html===!0&&(M(b,yt),M(S,Et)),ut.svg===!0&&(M(b,bt),M(S,Dt),M(S,kt)),ut.svgFilters===!0&&(M(b,xt),M(S,Dt),M(S,kt)),ut.mathMl===!0&&(M(b,Ct),M(S,Ot),M(S,kt))),w.tagCheck=null,w.attributeCheck=null,k(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?w.tagCheck=e.ADD_TAGS:nt(e.ADD_TAGS)&&(b===x&&(b=N(b)),M(b,e.ADD_TAGS,H))),k(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?w.attributeCheck=e.ADD_ATTR:nt(e.ADD_ATTR)&&(S===Ae&&(S=N(S)),M(S,e.ADD_ATTR,H))),k(e,`ADD_FORBID_CONTENTS`)&&nt(e.ADD_FORBID_CONTENTS)&&(dt===ft&&(dt=N(dt)),M(dt,e.ADD_FORBID_CONTENTS,H)),Xe&&(b[`#text`]=!0),Le&&M(b,[`html`,`head`,`body`]),b.table&&(M(b,[`tbody`]),delete je.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw mt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw mt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=g;g=e.TRUSTED_TYPES_POLICY;try{le=me(``)}catch(e){throw g=t,e}}else e.TRUSTED_TYPES_POLICY===null?(g=void 0,le=``):(g===void 0&&(g=_()),g&&typeof le==`string`&&(le=me(``)));D&&D(e),U=e},un=M({},[...bt,...xt,...St]),dn=M({},[...Ct,...wt]),fn=function(e,t,n){return t.namespaceURI===L?e===`svg`:t.namespaceURI===Wt?e===`svg`&&(n===`annotation-xml`||tn[n]):!!un[e]},pn=function(e,t,n){return t.namespaceURI===L?e===`math`:t.namespaceURI===Qt?e===`math`&&nn[n]:!!dn[e]},mn=function(e,t,n){return t.namespaceURI===Qt&&!nn[n]||t.namespaceURI===Wt&&!tn[n]?!1:!dn[e]&&(rn[e]||!un[e])},hn=function(e){let t=ne(e);(!t||!t.tagName)&&(t={namespaceURI:R,tagName:`template`});let n=rt(e.tagName),r=rt(t.tagName);return z[e.namespaceURI]?e.namespaceURI===Qt?fn(n,t,r):e.namespaceURI===Wt?pn(n,t,r):e.namespaceURI===L?mn(n,t,r):!!(an===`application/xhtml+xml`&&z[e.namespaceURI]):!1},W=function(e){et(t.removed,{element:e});try{ne(e).removeChild(e)}catch{if(p(e),!ne(e))throw mt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},gn=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},_n=function(e){yn(e);let t=te(e);if(t){let e=[];Ze(t,t=>{et(e,t)}),Ze(e,e=>{try{p(e)}catch{}})}let n=ie(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&gn(e,r,i)}},G=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}et(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ue||We)try{W(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},vn=function(e){let t=ie(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||S[H(i)]||gn(e,r,i)}},yn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();se(e)===F.element&&vn(e);let n=te(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},bn=function(e,t){return E?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},xn=function(e){if(!E)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=se(e);if(n===F.processingInstruction||n===F.comment&&A(Vt,e.data)){try{p(e)}catch{}continue}if(n===F.element){let t=e,n=H(ce(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&bn(`for`,n)&&t.removeAttribute(`for`)}catch{}}let r=te(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},Sn=function(e){let t=null,r=null;if(Ve)e=`<remove></remove>`+e;else{let t=at(e,/^[\r\n\t ]+/);r=t&&t[0]}an===`application/xhtml+xml`&&R===L&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=g?me(e):e;if(R===L)try{t=new l().parseFromString(i,an)}catch{}if(!t||!t.documentElement){t=_e.createDocument(R,`template`,null);try{t.documentElement.innerHTML=$t?le:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),R===L?ye.call(t,Le?`html`:`body`)[0]:Le?t.documentElement:a},Cn=function(e){let t=oe?oe(e):e.ownerDocument;return ve.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},wn=function(e){return e=ot(e,xe,` `),e=ot(e,Se,` `),e=ot(e,Ce,` `),e},Tn=function(e){e.normalize();let t=oe?oe(e):e.ownerDocument,n=ve.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=wn(r.data),r=n.nextNode();let i=e.querySelectorAll?.call(e,`template`);i&&Ze(i,e=>{K(e.content)&&Tn(e.content)})},En=function(e){let t=h?h(e):null;return typeof t!=`string`||H(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ie(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==ae(e)||e.childNodes!==te(e)},K=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return ae(e)===F.documentFragment}catch{return!1}},q=function(e){if(!ae||typeof e!=`object`||!e)return!1;try{return typeof ae(e)==`number`}catch{return!1}};function J(e,n,r){e.length!==0&&Ze(e,e=>{e.call(t,n,r,U)})}let Dn=function(e,t){return!!(E&&e.hasChildNodes()&&!q(e.firstElementChild)&&A(Bt,e.textContent)&&A(Bt,e.innerHTML)||E&&e.namespaceURI===L&&Gt[t]&&(q(e.firstElementChild)||typeof e.textContent==`string`&&A(Kt[t],e.textContent))||e.nodeType===F.processingInstruction||E&&e.nodeType===F.comment&&A(Vt,e.data))},On=function(e,t){return e instanceof RegExp?A(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},kn=function(e,t,n){if(!je[t]&&Fn(t)&&On(C.tagNameCheck,t))return!1;if(Xe&&!dt[t]){let t=ne(e),r=te(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,ee(e))}}}return W(e),!0},An=function(e,t,n,r){return e.length===0?t:t===n||t===r?N(t):t},jn=function(e,t){return e===t||ne(e)!==null?!1:(lt&&yn(e),!0)},Mn=function(e,n){if(J(y.beforeSanitizeElements,e,null),jn(e,n))return!0;if(En(e))return W(e),!0;let r=H(ce(e));if(b=An(y.uponSanitizeElement,b,x,ze),J(y.uponSanitizeElement,e,{tagName:r,allowedTags:b}),jn(e,n))return!0;if(Dn(e,r))return W(e),!0;if(je[r]||!(w.tagCheck instanceof Function&&w.tagCheck(r))&&!b[r]){let t=kn(e,r,n);return t===!1&&(J(y.afterSanitizeElements,e,null),jn(e,n))?!0:t}if(se(e)===F.element&&!hn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&A(Ht,e.innerHTML))return W(e),!0;if(T&&e.nodeType===F.text){let n=wn(e.textContent);e.textContent!==n&&(et(t.removed,{element:e.cloneNode()}),e.textContent=n)}return J(y.afterSanitizeElements,e,null),jn(e,n)},Nn=function(e,t,r){if(Me[t]||bn(t,e)||Ke&&(t===`id`||t===`name`)&&(r in n||r in sn))return!1;let i=S[t]||w.attributeCheck instanceof Function&&w.attributeCheck(t,e);return Pe&&A(we,t)||Ne&&A(Te,t)?!0:i?ht[t]||A(ke,ot(r,De,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&st(r,`data:`)===0&&pt[e]||Fe&&!A(Ee,ot(r,De,``))?!0:!r:Fn(e)&&On(C.tagNameCheck,e)&&On(C.attributeNameCheck,t,e)||t===`is`&&C.allowCustomizedBuiltInElements&&On(C.tagNameCheck,r)},Pn=M({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Fn=function(e){return!Pn[rt(e)]&&A(Oe,e)},In=function(e,t,n,r){if(g&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return me(r);case`TrustedScriptURL`:return he(r)}return r},Ln=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!En(e)||(W(e),!1)}catch{return G(t,e),!1}},Rn=function(e,n){if(J(y.beforeSanitizeAttributes,e,null),jn(e,n))return;let r=e.attributes;if(!r||En(e))return;S=An(y.uponSanitizeAttribute,S,Ae,Be);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:S,forceKeepAttr:void 0},a=r.length,o=H(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=H(s),d=l,f=s===`value`?d:ct(d),p=!1;if(i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,J(y.uponSanitizeAttribute,e,i),f=i.attrValue,Je&&(u===`id`||u===`name`)&&st(f,Ye)!==0&&(G(s,e,n),f=Ye+f,p=!0),E&&A(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,f)){G(s,e,n);continue}if(u===`attributename`&&at(f,`href`)){G(s,e,n);continue}if(!i.forceKeepAttr){if(!i.keepAttr){G(s,e,n);continue}if(!Ie&&A(Ut,f)){G(s,e,n);continue}if(T&&(f=wn(f)),!Nn(o,u,f)){G(s,e,n);continue}f=In(o,u,c,f),f!==d&&Ln(e,s,c,f)&&p&&$e(t.removed)}}J(y.afterSanitizeAttributes,e,null),jn(e,n)},zn=function(e){let t=null,n=Cn(e);for(J(y.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(J(y.uponSanitizeShadowNode,t,null),Mn(t,e),Rn(t,e),K(t.content)&&zn(t.content),se(t)===F.element){let e=re(t);K(e)&&(Bn(e),zn(e))}J(y.afterSanitizeShadowDOM,e,null)},Bn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){zn(e.shadow);continue}let n=e.node,r=se(n)===F.element,i=te(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=h?h(n):null;if(typeof e==`string`&&H(e)===`template`){let e=n.content;K(e)&&t.push({node:e,shadow:null})}}if(r){let e=re(n);K(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if($t=!e,$t&&(e=`<!-->`),typeof e!=`string`&&!q(e)&&(e=_t(e),typeof e!=`string`))throw mt(`dirty is not a string, aborting`);if(!t.isSupported)return e;Re?(b=ze,S=Be):ln(n),(y.uponSanitizeElement.length>0||y.uponSanitizeAttribute.length>0)&&(b=N(b)),y.uponSanitizeAttribute.length>0&&(S=N(S)),t.removed=[];let c=lt&&typeof e!=`string`&&q(e);if(c){xn(e);let t=ce(e);if(typeof t==`string`){let n=H(t);if(!b[n]||je[n])throw _n(e),mt(`root node is forbidden and cannot be sanitized in-place`)}if(En(e))throw _n(e),mt(`root node is clobbered and cannot be sanitized in-place`);try{Bn(e)}catch(t){throw _n(e),t}}else if(q(e))i=Sn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===F.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Bn(i);else{if(!Ue&&!T&&!Le&&e.indexOf(`<`)===-1)return g&&Ge?me(e):e;if(i=Sn(e),!i)return Ue?null:Ge?le:``}i&&Ve&&W(i.firstChild);let l=c?e:i;try{let e=Cn(l);for(;o=e.nextNode();)Mn(o,l),Rn(o,l),K(o.content)&&zn(o.content)}catch(n){throw c&&(_n(e),Ze(t.removed,e=>{e.element&&yn(e.element)})),n}if(c){let n=!1;if(Ze(t.removed,t=>{t.element&&(t.element===e&&(n=!0),yn(t.element))}),n)throw mt(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return T&&Tn(e),e}if(Ue){if(T&&Tn(i),We)for(s=v.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(S.shadowroot||S.shadowrootmode)&&(s=be.call(r,s,!0)),s}let u=Le?i.outerHTML:i.innerHTML;return Le&&b[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&A(Rt,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
3
3
  `+u),T&&(u=wn(u)),g&&Ge?me(u):u},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ln(e),Re=!0,ze=b,Be=S},t.clearConfig=function(){U=null,Re=!1,ze=null,Be=null,g=ue,le=``},t.isValidAttribute=function(e,t,n){U||ln({});let r=H(e),i=H(t);return Nn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&k(y,e)&&et(y[e],t)},t.removeHook=function(e,t){if(k(y,e)){if(t!==void 0){let n=Qe(y[e],t);return n===-1?void 0:tt(y[e],n,1)[0]}return $e(y[e])}},t.removeHooks=function(e){k(y,e)&&(y[e]=[])},t.removeAllHooks=function(){y=Yt()},t}var Qt=Zt();function L(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var R=L();function $t(e){R=e}var z={exec:()=>null};function en(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function B(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(V.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var tn=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),V={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/g,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:en(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:en(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:en(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:en(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:en(e=>RegExp(`^ {0,${e}}(?:</?(?:${hn})(?: +|$|/?>)|<(?:script|pre|style|textarea|!--))`,`i`)),blockquoteBeginRegex:en(e=>RegExp(`^ {0,${e}}>`))},nn=/^(?:[ \t]*(?:\n|$))+/,rn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,an=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,on=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,H=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,U=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,sn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,cn=B(sn).replace(/bull/g,U).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),ln=B(sn).replace(/bull/g,U).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),un=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,dn=/^[^\n]+/,fn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,pn=B(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,fn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),mn=B(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,U).getRegex(),hn=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,W=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,gn=B(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,W).replace(`tag`,hn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),_n=e=>B(un).replace(`hr`,on).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,hn).getRegex(),G=_n(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),vn=_n(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),yn={blockquote:B(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,vn).getRegex(),code:rn,def:pn,fences:an,heading:H,hr:on,html:gn,lheading:cn,list:mn,newline:nn,paragraph:G,table:z,text:dn},bn=B(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,on).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,hn).getRegex(),xn={...yn,lheading:ln,table:bn,paragraph:B(un).replace(`hr`,on).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,bn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,hn).getRegex()},Sn={...yn,html:B(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,W).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:z,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:B(un).replace(`hr`,on).replace(`heading`,` *#{1,6} *[^
4
4
  ]`).replace(`lheading`,cn).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Cn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,wn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Tn=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,En=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,K=/[\p{P}\p{S}]/u,q=/[\s\p{P}\p{S}]/u,J=/[^\s\p{P}\p{S}]/u,Dn=B(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,q).getRegex(),On=/[\p{Pi}\p{Ps}"']/u,kn=/(?!~)[\p{P}\p{S}]/u,An=/(?!~)[\s\p{P}\p{S}]/u,jn=/(?:[^\s\p{P}\p{S}]|~)/u,Mn=B(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,tn?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Nn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Pn=B(Nn,`u`).replace(/punct/g,K).getRegex(),Fn=B(Nn,`u`).replace(/punct/g,kn).getRegex(),In=B(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,On).replace(/punct/g,K).getRegex(),Ln=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Rn=B(Ln,`gu`).replace(/notPunctSpace/g,J).replace(/punctSpace/g,q).replace(/punct/g,K).getRegex(),zn=B(Ln,`gu`).replace(/notPunctSpace/g,jn).replace(/punctSpace/g,An).replace(/punct/g,kn).getRegex(),Bn=B(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,J).replace(/punctSpace/g,q).replace(/punct/g,K).getRegex(),Vn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,J).replace(/punctSpace/g,q).replace(/punct/g,K).getRegex(),Hn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,J).replace(/punctSpace/g,q).replace(/punct/g,K).getRegex(),Un=B(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,K).getRegex(),Wn=B(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,J).replace(/punctSpace/g,q).replace(/punct/g,K).getRegex(),Gn=B(/\\(punct)/,`gu`).replace(/punct/g,K).getRegex(),Kn=B(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),qn=B(W).replace(`(?:-->|$)`,`-->`).getRegex(),Jn=B(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,qn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Yn=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Xn=B(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,Yn).getRegex(),Zn=B(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Xn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Qn=B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Xn).replace(`ref`,fn).getRegex(),$n=B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,fn).getRegex(),er=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,tr=B(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,Yn).getRegex(),nr=B(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,tr).replace(`ref`,er).getRegex()).replace(`nolink`,B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,er).getRegex()).getRegex(),rr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ir=B(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),ar={_backpedal:z,anyPunctuation:Gn,autolink:Kn,blockSkip:Mn,br:Tn,code:wn,del:z,delLDelim:z,delRDelim:z,emStrongLDelim:Pn,emStrongRDelimAst:Rn,emStrongRDelimUnd:Vn,escape:Cn,link:Zn,nolink:$n,punctuation:Dn,reflink:Qn,reflinkSearch:nr,tag:Jn,text:En,url:z},or={...ar,emStrongLDelim:In,emStrongRDelimAst:Bn,emStrongRDelimUnd:Hn,link:B(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Xn).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Xn).getRegex()},sr={...ar,emStrongRDelimAst:zn,emStrongLDelim:Fn,delLDelim:Un,delRDelim:Wn,url:B(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,ir).replace(`protocol`,rr).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:B(/^(?:[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,rr).replace(/emailProtocol/g,/(?:mailto|xmpp):/).getRegex()},cr={...sr,br:B(Tn).replace(`{2,}`,`*`).getRegex(),text:B(sr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},lr={normal:yn,gfm:xn,pedantic:Sn},ur={normal:ar,gfm:sr,breaks:cr,pedantic:or},dr={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},fr=e=>dr[e];function Y(e,t){if(t){if(V.escapeTest.test(e))return e.replace(V.escapeReplace,fr)}else if(V.escapeTestNoEncode.test(e))return e.replace(V.escapeReplaceNoEncode,fr);return e}function pr(e){return e.replace(V.numericCharacterReference,(e,t,n)=>{let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:String.fromCodePoint(r)})}function mr(e){try{e=encodeURI(e).replace(V.percentDecode,`%`)}catch{return null}return e}function hr(e,t){let n=e.replace(V.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(V.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(V.slashPipe,`|`);return n}function gr(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function _r(e){let t=e.split(`
@@ -31,7 +31,7 @@
31
31
  dispatchEvent(new Event("wizard-install"));
32
32
  });
33
33
  </script>
34
- <script type="module" crossorigin src="/studio/assets/index-BAQ2e4is.js"></script>
34
+ <script type="module" crossorigin src="/studio/assets/index-Bl5vhqT3.js"></script>
35
35
  <link rel="modulepreload" crossorigin href="/studio/assets/jsx-runtime-D3jfb0Ew.js">
36
36
  <link rel="modulepreload" crossorigin href="/studio/assets/preload-helper-CNEI7N0N.js">
37
37
  <link rel="modulepreload" crossorigin href="/studio/assets/createLucideIcon-q3MZMmnf.js">
@@ -58,11 +58,20 @@ export interface PluginRoute {
58
58
  */
59
59
  handler(request: PluginRequest): unknown | Promise<unknown>;
60
60
  }
61
+ /** A space: what all its wizards share. The runtime's own tables call it a project. */
62
+ export interface PluginSpace {
63
+ id: string;
64
+ /** What the studio's switcher calls it. */
65
+ name: string;
66
+ }
61
67
  /** What a tool knows about the step that calls it. */
62
68
  export interface PluginStepContext {
63
69
  runId: string;
64
70
  stepId: string;
65
71
  tenantId: string;
72
+ /** The space of the step's wizard. */
73
+ space: PluginSpace;
74
+ /** The same as `space`, by its older name. */
66
75
  project: {
67
76
  id: string;
68
77
  name: string;
@@ -102,10 +111,33 @@ export interface PluginRunEvent {
102
111
  /** What the person answered, by field id. */
103
112
  values: Record<string, unknown>;
104
113
  }
114
+ /** A space was made, changed (title, about, colours, facts, systems) or deleted. */
115
+ export interface PluginSpaceEvent {
116
+ space: {
117
+ id: string;
118
+ };
119
+ }
120
+ /** A file of a space: read and ready (a document is in the index then), or removed. */
121
+ export interface PluginSpaceFileEvent {
122
+ space: {
123
+ id: string;
124
+ };
125
+ file: {
126
+ id: string;
127
+ name: string;
128
+ kind: "logo" | "asset" | "document";
129
+ mime: string;
130
+ };
131
+ }
105
132
  export interface PluginEvents {
106
133
  "run.done": PluginRunEvent;
107
134
  "run.failed": PluginRunEvent;
108
135
  "run.cancelled": PluginRunEvent;
136
+ "space.created": PluginSpaceEvent;
137
+ "space.updated": PluginSpaceEvent;
138
+ "space.deleted": PluginSpaceEvent;
139
+ "space.file.ready": PluginSpaceFileEvent;
140
+ "space.file.removed": PluginSpaceFileEvent;
109
141
  }
110
142
  /** The tenant's database. A plugin reads and writes its own tables with it. */
111
143
  export type PluginDb = LibSQLDatabase<Record<string, never>>;
@@ -126,9 +158,160 @@ export interface PluginGenerateResult<T = undefined> {
126
158
  /** Set when the request had a `schema`. */
127
159
  object: T;
128
160
  }
161
+ /** What a plugin adds to every agent step of a space's wizards. */
162
+ export interface PluginSpaceContext {
163
+ /**
164
+ * A block of the step's instructions, after what the space says about itself and its
165
+ * documents: what the plugin holds for the space, and which of its tools read it. Empty or
166
+ * null: the step gets neither the block nor the tools.
167
+ */
168
+ block(space: PluginSpace): string | null | Promise<string | null>;
169
+ /** Tools the step gets with the block, named `<plugin>_<name>` for the model. */
170
+ tools?: PluginTool[];
171
+ }
172
+ /** A text a plugin puts into a space's search index, beside the space's documents. */
173
+ export interface PluginIndexEntry {
174
+ /** The space's id. */
175
+ space: string;
176
+ /** The plugin's own name for it: putting the same key again replaces what it had. */
177
+ key: string;
178
+ /** What a hit is called: a page's title, a question. */
179
+ title: string;
180
+ /** Markdown, cut into passages like a document's text. */
181
+ text: string;
182
+ /** Where the studio shows it, an address of the studio: `/space#faq`. */
183
+ link?: string;
184
+ }
185
+ export interface PluginIndex {
186
+ /** Puts the entry in; `project_search` finds it from then on. */
187
+ put(entry: PluginIndexEntry): Promise<void>;
188
+ /** Takes one key out, or without a key every entry of the plugin in the space. */
189
+ remove(space: string, key?: string): Promise<void>;
190
+ }
191
+ /** What a tool of the space assistant knows about the turn that calls it. */
192
+ export interface PluginAssistantContext {
193
+ tenantId: string;
194
+ space: PluginSpace;
195
+ /** The person talking to the assistant. */
196
+ userId: string;
197
+ /** Aborted when the person leaves or stops the turn. */
198
+ signal: AbortSignal;
199
+ /** Tells the person what the assistant is doing right now: "Liest die Sitemap …". */
200
+ emit(message: string): void;
201
+ /** Say so when the tool changed what the space page shows: the page draws it again. */
202
+ changed(): void;
203
+ }
204
+ /** A tool of the space assistant: the chat on the space page that fills the space in. */
205
+ export interface PluginAssistantTool<S extends z.ZodType = z.ZodType> {
206
+ /** Lower case, digits and `_`. The model sees it as `<plugin>_<name>`. */
207
+ name: string;
208
+ /** For the model: what the tool does and when to use it. */
209
+ description: string;
210
+ inputSchema: S;
211
+ /**
212
+ * The result also goes to the chat, where the card the studio half registered for this tool
213
+ * (`registerAssistantCard`) draws it. It is sent as it is: keep such a result small.
214
+ */
215
+ card?: boolean;
216
+ execute(input: z.infer<S>, ctx: PluginAssistantContext): unknown | Promise<unknown>;
217
+ }
218
+ /** A page of the web, as `web.read` gives it. */
219
+ export interface PluginWebPage {
220
+ /** Where it ended up, after redirects. */
221
+ url: string;
222
+ status: number;
223
+ /** As the server sent them, for asking later whether the page changed. */
224
+ etag: string | null;
225
+ lastModified: string | null;
226
+ title: string;
227
+ description: string;
228
+ /** The page's text as Markdown. */
229
+ text: string;
230
+ /** Every link of the page, absolute, each once. */
231
+ links: {
232
+ url: string;
233
+ text: string;
234
+ }[];
235
+ }
236
+ export interface PluginWeb {
237
+ /**
238
+ * `fetch`, behind the guard of the runtime's own requests: addresses of this machine and of
239
+ * the local network are refused, after a redirect too.
240
+ */
241
+ fetch(url: string, init?: RequestInit): Promise<Response>;
242
+ /**
243
+ * A page read the way the space assistant reads one: guarded as `fetch`, and drawn in a
244
+ * browser when it has hardly any text without its scripts.
245
+ */
246
+ read(url: string, options?: {
247
+ signal?: AbortSignal;
248
+ }): Promise<PluginWebPage>;
249
+ }
250
+ export interface PluginDocuments {
251
+ /**
252
+ * A file as Markdown: PDF and Word by their text, scans and photos by a vision model (paid
253
+ * like every model call), spreadsheets as tables. Kept by content: the same bytes are read once.
254
+ */
255
+ parse(file: {
256
+ data: Uint8Array;
257
+ name: string;
258
+ mime: string;
259
+ }, options?: {
260
+ signal?: AbortSignal;
261
+ }): Promise<{
262
+ markdown: string;
263
+ pages: number | null;
264
+ }>;
265
+ }
266
+ /** One turn of a job `every` runs. */
267
+ export interface PluginTick {
268
+ tenantId: string;
269
+ /** When it ran for this tenant before; null the first time. */
270
+ lastRun: Date | null;
271
+ /** Aborted when the plugin unloads. */
272
+ signal: AbortSignal;
273
+ }
274
+ /** What a public route's handler gets. Nobody is signed in. */
275
+ export interface PluginPublicRequest {
276
+ request: Request;
277
+ /** The address below the plugin's public one. */
278
+ path: string;
279
+ params: Record<string, string>;
280
+ query: URLSearchParams;
281
+ /** The tenant whose address was called; the handler runs inside it. */
282
+ tenantId: string;
283
+ json<T = unknown>(): Promise<T>;
284
+ }
285
+ /**
286
+ * A route anyone may call, below the address `publicUrl` gives: a CMS that says a page
287
+ * changed, a service's webhook. Check a secret of your own in it, a token or a signature.
288
+ */
289
+ export interface PluginPublicRoute {
290
+ method: PluginHttpMethod;
291
+ path: string;
292
+ handler(request: PluginPublicRequest): unknown | Promise<unknown>;
293
+ }
129
294
  export interface PluginServerApi {
130
295
  registerHttpRoute(route: PluginRoute): void;
131
296
  registerTool<S extends z.ZodType>(tool: PluginTool<S>): void;
297
+ /** A block and tools for every agent step of a space's wizards. */
298
+ registerSpaceContext(context: PluginSpaceContext): void;
299
+ /** A tool of the space assistant. */
300
+ registerAssistantTool<S extends z.ZodType>(tool: PluginAssistantTool<S>): void;
301
+ registerPublicRoute(route: PluginPublicRoute): void;
302
+ /** The full address of a public route for the current tenant: what to hand to whoever calls it. */
303
+ publicUrl(path: string): Promise<string>;
304
+ /**
305
+ * Runs `handler` for every tenant that has the plugin, at most once per `everyMs` (a minute
306
+ * at least), inside that tenant. When it ran is kept: a restart does not start the count again,
307
+ * and a runtime that was off runs it once when it starts, not once per turn it missed. One turn
308
+ * per tenant at a time; a turn that throws counts as run.
309
+ */
310
+ every(name: string, everyMs: number, handler: (tick: PluginTick) => void | Promise<void>): void;
311
+ /** The space's search index, which `project_search` asks. */
312
+ index: PluginIndex;
313
+ web: PluginWeb;
314
+ documents: PluginDocuments;
132
315
  /**
133
316
  * A folder of `.sql` files with the plugin's own tables. Every tenant database gets each file
134
317
  * once, in the order of the file names. Nothing is taken back when the plugin unloads.
@@ -1,9 +1,10 @@
1
1
  import type { ComponentType } from "react";
2
2
  /**
3
3
  * What the studio hands a plugin's studio half: the built `client.js` the studio loads after
4
- * sign-in. Its default export registers pages, entries of the top bar and sections of the
5
- * settings. React, the router and the studio's own components come from the studio
6
- * (docs/content/dev/plugins), so the page a plugin draws is part of the same app.
4
+ * sign-in. Its default export registers pages, entries of the top bar, sections of the settings
5
+ * and of the space page, and cards of the space assistant's chat. React, the router and the
6
+ * studio's own components come from the studio (docs/content/dev/plugins), so the page a plugin
7
+ * draws is part of the same app.
7
8
  */
8
9
  export type StudioLang = "de" | "en";
9
10
  /** A plugin's words. `de` is the source: a key missing in `en` shows the German. */
@@ -34,6 +35,43 @@ export interface StudioSettingsSection {
34
35
  /** The user menu links to it directly. */
35
36
  menu?: boolean;
36
37
  }
38
+ /**
39
+ * A section of the space page, below the space's own sections. The studio draws its heading and
40
+ * hint above it, and its entry in the page's menu under the plugin's name; the component draws
41
+ * the rest, usually a `Card`.
42
+ */
43
+ export interface StudioSpaceSection {
44
+ /** Its anchor on the page: `/space#<id>`. */
45
+ id: string;
46
+ label: () => string;
47
+ /** One line under the heading: what the section is for. */
48
+ hint?: () => string;
49
+ component: ComponentType;
50
+ }
51
+ /** What a card in the assistant's chat is handed. */
52
+ export interface StudioAssistantCardProps<T = unknown> {
53
+ /** What the assistant tool returned. */
54
+ data: T;
55
+ /** Sends a message to the assistant, as if the person typed it: "Übernehmen". */
56
+ send(message: string): void;
57
+ }
58
+ /**
59
+ * Draws the result of a tool of the space assistant inside its chat: a tool the server half
60
+ * registered with `card: true`.
61
+ */
62
+ export interface StudioAssistantCard {
63
+ /** The tool's name, as the server half registered it. */
64
+ tool: string;
65
+ component: ComponentType<StudioAssistantCardProps<any>>;
66
+ }
67
+ /** The space the studio shows: what all its wizards share. */
68
+ export interface StudioSpace {
69
+ id: string;
70
+ /** What the switcher calls it. */
71
+ name: string;
72
+ /** Synced from a local install, or on a runtime where nothing is built: shown, not changed. */
73
+ readOnly: boolean;
74
+ }
37
75
  export interface StudioMe {
38
76
  user: {
39
77
  id: string;
@@ -56,6 +94,13 @@ export interface StudioPluginContext {
56
94
  registerPage(page: StudioPage): void;
57
95
  registerNav(entry: StudioNavEntry): void;
58
96
  registerSettingsSection(section: StudioSettingsSection): void;
97
+ registerSpaceSection(section: StudioSpaceSection): void;
98
+ registerAssistantCard(card: StudioAssistantCard): void;
99
+ /**
100
+ * A hook: the space the studio shows, `null` while it has none. A component that calls it draws
101
+ * again when the person picks another space.
102
+ */
103
+ useSpace(): StudioSpace | null;
59
104
  i18n: {
60
105
  /** Takes the plugin's words and gives the function that reads them in the language in effect. */
61
106
  register<M extends StudioMessages>(messages: M): (key: keyof M["de"] & string, vars?: Record<string, string | number>) => string;
@@ -65,8 +65,14 @@ export declare const PROJECT_LIMITS: {
65
65
  export declare function projectFileLimit(kind: ProjectFileKind, mime: string): number;
66
66
  /** One passage the document index found for a question. */
67
67
  export interface ProjectSearchHit {
68
- fileId: string;
68
+ /** The document the passage is of; null for a plugin's text. */
69
+ fileId: string | null;
70
+ /** The plugin whose text it is; null for a document. */
71
+ plugin: string | null;
72
+ /** The document's name, or the title of the plugin's text. */
69
73
  name: string;
74
+ /** Where the studio shows a plugin's text. */
75
+ link: string | null;
70
76
  /** The passage's place in its document, from 0. */
71
77
  index: number;
72
78
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wizards",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Make a wish. Get your wizard. It guides you step by step. Let AI do the work. Runs on your machine, on the AI subscription you already have.",
5
5
  "license": "FSL-1.1-MIT",
6
6
  "homepage": "https://engenty.ai",
@@ -1 +0,0 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{c as r,j as i,n as a,nt as o}from"./api-u3nydnnp.js";import{t as s}from"./createLucideIcon-q3MZMmnf.js";import{t as c}from"./check-CUpby_J9.js";import{n as l,r as u}from"./upload-DNRENWzQ.js";import{t as d}from"./external-link-MAL7vJYj.js";import{_ as f,c as p,d as m,h,m as g,n as _,o as ee,r as v,s as y,t as b,y as x}from"./ui-gGAdXx-P.js";import{A as S,D as C,F as w,_ as T,f as E,o as D,p as O,u as k}from"./index-BAQ2e4is.js";import{n as A}from"./LocalRuntime-DFswQjxc.js";var j={name:`hard-drive`,size:24,node:[[`path`,{d:`M10 16h.01`,key:`1bzywj`}],[`path`,{d:`M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`18tbho`}],[`path`,{d:`M21.946 12.013H2.054`,key:`zqlbp7`}],[`path`,{d:`M6 16h.01`,key:`1pmjb7`}]]};j.node;var M=s(j),N={name:`layout-grid`,size:24,node:[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]};N.node;var P=s(N),F={name:`list`,size:24,node:[[`path`,{d:`M3 5h.01`,key:`18ugdj`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M3 19h.01`,key:`noohij`}],[`path`,{d:`M8 5h13`,key:`1pao27`}],[`path`,{d:`M8 12h13`,key:`1za7za`}],[`path`,{d:`M8 19h13`,key:`m83p4d`}]]};F.node;var I=s(F),L=e(t(),1),R=e=>[`project-files`,e];function z(e){return i({queryKey:R(e),queryFn:()=>a.get(`/api/studio/projects/${e}/files`),refetchInterval:e=>e.state.data?.files.some(e=>e.status===`pending`)?2e3:!1})}function B(e,t){return r(`/api/studio/projects/${e}/files/${t}/content`)}function V(e,t=!1){let n=o(),[r,i]=(0,L.useState)(!1),[s,c]=(0,L.useState)(null),l=()=>n.invalidateQueries({queryKey:R(e)}),u=async e=>{c(null);try{await e()}catch(e){c(e.message)}finally{await l()}};return{busy:r,error:s,readOnly:t,upload:async(t,n)=>{i(!0),await u(async()=>{for(let r of n)await a.upload(`/api/studio/projects/${e}/files?kind=${t}`,r),await l()}),i(!1)},describe:(t,n)=>u(()=>a.patch(`/api/studio/projects/${e}/files/${t}`,{description:n})),remove:t=>u(()=>a.del(`/api/studio/projects/${e}/files/${t}`)),reindex:t=>u(()=>a.post(`/api/studio/projects/${e}/files/${t}/reindex`)),order:(t,n)=>u(()=>a.put(`/api/studio/projects/${e}/files/order`,{kind:t,ids:n}))}}function H(e,t){let n=`wz.layout.${e}`,[r,i]=(0,L.useState)(()=>{try{let e=localStorage.getItem(n);return e===`list`||e===`cards`?e:t}catch{return t}});return[r,()=>i(e=>{let t=e===`list`?`cards`:`list`;try{localStorage.setItem(n,t)}catch{}return t})]}function U(e,t,n=700){let[r,i]=(0,L.useState)(`idle`),[a,o]=(0,L.useState)(null),s=JSON.stringify(e),c=(0,L.useRef)(s),l=(0,L.useRef)({value:e,json:s,save:t});l.current={value:e,json:s,save:t};let u=(0,L.useRef)(Promise.resolve()),d=(0,L.useCallback)(()=>{let e=l.current;e.json!==c.current&&(c.current=e.json,i(`saving`),u.current=u.current.then(async()=>{try{await e.save(e.value),o(null),i(`saved`)}catch(e){c.current=``,o(e.message),i(`error`)}}))},[]);return(0,L.useEffect)(()=>{if(s===c.current)return;let e=setTimeout(d,n);return()=>clearTimeout(e)},[s,n,d]),(0,L.useEffect)(()=>d,[d]),{state:r,error:a}}function W(e){return e<1e6?`${Math.max(1,Math.round(e/1e3))} KB`:`${(e/1e6).toFixed(1)} MB`}var G=e(n(),1);function K({title:e,hint:t,save:n,action:r,locked:i,children:a}){return(0,G.jsxs)(`section`,{className:`flex flex-col gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4 px-1`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(`h2`,{className:`font-display font-semibold text-lg leading-tight`,children:e}),n?.state===`saving`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[12px] text-ink-3`,children:[(0,G.jsx)(m,{className:`size-3`}),` `,x(`project.saving`)]}):n?.state===`saved`?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[12px] text-moss`,children:[(0,G.jsx)(c,{className:`size-3.5`}),` `,x(`settings.saved`)]}):null]}),t?(0,G.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-3 leading-snug`,children:t}):null]}),r?(0,G.jsx)(`div`,{className:`shrink-0`,children:r}):null]}),(0,G.jsxs)(_,{className:`p-5`,children:[i?(0,G.jsx)(`fieldset`,{disabled:!0,className:`min-w-0`,children:a}):a,n?.state===`error`&&n.error?(0,G.jsx)(`p`,{className:`mt-4 text-[14px] text-rose`,children:n.error}):null]})]})}function q({children:e,layout:t,onToggle:n}){return(0,G.jsxs)(`div`,{className:`mb-3 flex items-start gap-2`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(`div`,{className:`w-56 max-w-full transition-[width] duration-200 focus-within:w-full has-[input:not(:placeholder-shown)]:w-full`,children:e})}),(0,G.jsx)(ee,{label:x(t===`list`?`project.viewCards`:`project.viewList`),onClick:n,children:t===`list`?(0,G.jsx)(P,{className:`size-4`}):(0,G.jsx)(I,{className:`size-4`})})]})}function J({value:e,onChange:t,onEnter:n,placeholder:r,busy:i}){return(0,G.jsxs)(`div`,{className:`relative`,children:[(0,G.jsx)(l,{className:`-translate-y-1/2 pointer-events-none absolute top-1/2 left-3 size-4 text-ink-4`}),(0,G.jsx)(`input`,{type:`search`,value:e,placeholder:r,onChange:e=>t(e.target.value),onKeyDown:e=>e.key===`Enter`&&n?.(),className:`h-9 w-full rounded-lg border border-input bg-card pr-3 pl-9 text-[14px] text-ink outline-none transition placeholder:text-ink-4 focus:border-focus focus:ring-4 focus:ring-focus-glow`}),i?(0,G.jsx)(m,{className:`-translate-y-1/2 absolute top-1/2 right-3 size-4 text-ink-3`}):null]})}function Y({onFiles:e,accept:t,multiple:n=!0,className:r,children:i}){return(0,G.jsxs)(`label`,{onDragOver:e=>{e.preventDefault(),e.currentTarget.dataset.over=`1`},onDragLeave:e=>{delete e.currentTarget.dataset.over},onDrop:t=>{t.preventDefault(),delete t.currentTarget.dataset.over;let r=Array.from(t.dataTransfer.files);r.length&&e(n?r:r.slice(0,1))},className:h(`flex cursor-pointer items-center justify-center gap-2 rounded-lg border border-input border-dashed text-[14px] text-ink-3 transition focus-within:border-focus focus-within:ring-4 focus-within:ring-focus-glow hover:border-ink-4 hover:text-ink data-[over]:border-focus data-[over]:bg-paper-2 data-[over]:text-ink`,r),children:[i,(0,G.jsx)(`input`,{className:`sr-only`,type:`file`,accept:t,multiple:n,onChange:t=>{let n=Array.from(t.target.files??[]);t.target.value=``,n.length&&e(n)}})]})}var X=`mt-1.5 text-[13px] text-ink-3`;function Z(e){let t=o(),[n,r]=(0,L.useState)(!1),i=w({mutationFn:e=>a.post(`/api/studio/account/link`,e),onSuccess:({url:e})=>{A(e),r(!0)}});return(0,L.useEffect)(()=>{if(!n)return;let e=setInterval(()=>void t.invalidateQueries({queryKey:[`me`]}),2e3),i=setTimeout(()=>r(!1),3e5);return()=>{clearInterval(e),clearTimeout(i)}},[n,t]),(0,L.useEffect)(()=>{e&&r(!1)},[e]),{link:i,waiting:n}}function Q({link:e,waiting:t}){return e.isError?(0,G.jsx)(`p`,{className:`text-[13px] text-rose`,children:x(`local.accountFailed`)}):t?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-[13px] text-ink-3`,children:[(0,G.jsx)(m,{className:`size-3.5`}),` `,x(`local.accountWaiting`)]}):null}function te(){let e=Z(!1),{link:t}=e,[n,r]=(0,L.useState)(``);return(0,G.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-4 py-5 first:pt-0 last:pb-0`,children:[(0,G.jsx)(`div`,{className:`flex size-11 shrink-0 items-center justify-center rounded-full bg-paper-2 text-ink-2`,children:(0,G.jsx)(M,{className:`size-5`})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`font-medium text-[15px]`,children:x(`account.local`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-3 leading-relaxed`,children:x(`account.localText`)})]})]}),O.account?(0,G.jsxs)(`div`,{className:`flex flex-col gap-4 py-5 last:pb-0`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium text-[15px]`,children:x(`account.with`)}),(0,G.jsxs)(`ul`,{className:`mt-2 flex flex-col gap-2 text-[14px] text-ink-2 leading-snug`,children:[(0,G.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,G.jsx)(u,{className:`mt-0.5 size-4 shrink-0 text-amber`}),x(`account.withCredits`)]}),(0,G.jsxs)(`li`,{className:`flex items-start gap-2.5`,children:[(0,G.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),x(`account.withCloud`)]})]})]}),(0,G.jsx)(`div`,{children:(0,G.jsx)(b,{busy:t.isPending&&!t.variables?.signup,onClick:()=>t.mutate({}),children:x(`account.signIn`)})})]}):null,O.account?(0,G.jsxs)(`form`,{className:`flex flex-col gap-3 py-5 last:pb-0`,onSubmit:e=>{e.preventDefault(),t.mutate({signup:!0,code:n.trim()||void 0})},children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium text-[15px]`,children:x(`account.new`)}),(0,G.jsx)(`p`,{className:`mt-1 text-[14px] text-ink-3 leading-relaxed`,children:x(`account.newHint`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(y,{value:n,maxLength:64,autoComplete:`off`,spellCheck:!1,placeholder:x(`account.code`),"aria-label":x(`account.code`),onChange:e=>r(e.target.value),className:`w-56 font-mono text-[14px]`}),(0,G.jsx)(b,{type:`submit`,variant:`secondary`,className:`h-11`,busy:t.isPending&&!!t.variables?.signup,children:x(`account.create`)})]}),(0,G.jsx)(Q,{...e})]}):null]})}var $={start:`account.kind.start`,monthly:`account.kind.monthly`,gift:`account.kind.gift`};function ne({account:e}){let t=o(),n=Z(e.signedIn),r=w({mutationFn:()=>a.del(`/api/studio/account`),onSuccess:()=>t.invalidateQueries({queryKey:[`me`]})}),i=new Intl.DateTimeFormat(f,{dateStyle:`medium`});return(0,G.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3 py-5 first:pt-0`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate font-medium text-[15px]`,children:e.name||e.email}),e.signedIn?(0,G.jsx)(v,{tone:`live`,children:x(`account.linked`)}):null]}),(0,G.jsx)(`div`,{className:`truncate text-[14px] text-ink-3`,children:e.email})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(b,{variant:`secondary`,onClick:()=>A(e.url),children:[x(`setup.openAccount`),` `,(0,G.jsx)(d,{className:`size-4`})]}),(0,G.jsxs)(b,{variant:`ghost`,busy:r.isPending,onClick:()=>r.mutate(),children:[(0,G.jsx)(C,{className:`size-4`}),` `,x(`nav.logout`)]})]})]}),e.signedIn?null:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 py-5`,children:[(0,G.jsx)(`p`,{className:`text-[14px] text-ink-2`,children:x(`local.accountExpired`)}),(0,G.jsx)(`div`,{children:(0,G.jsx)(b,{busy:n.link.isPending,onClick:()=>n.link.mutate({}),children:x(`account.signInAgain`)})}),(0,G.jsx)(Q,{...n})]}),e.credits===null?null:(0,G.jsxs)(`div`,{className:`py-5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-[13px] text-ink-3`,children:x(`account.credits`)}),(0,G.jsx)(`div`,{className:`font-display font-semibold text-[22px] tabular-nums leading-tight`,children:x(`nav.credits`,{n:Math.floor(e.credits).toLocaleString()})})]}),(0,G.jsxs)(b,{variant:`secondary`,onClick:()=>A(`${e.url}/billing`),children:[x(`account.topUp`),` `,(0,G.jsx)(d,{className:`size-4`})]})]}),e.expiring.length?(0,G.jsx)(`ul`,{className:`mt-3 flex flex-col gap-1 text-[13px] text-ink-3 tabular-nums`,children:e.expiring.map(e=>(0,G.jsxs)(`li`,{children:[x(`account.expires`,{n:Math.floor(e.credits).toLocaleString(),date:i.format(new Date(e.expiresAt))}),$[e.kind]?(0,G.jsxs)(`span`,{className:`text-ink-4`,children:[` · `,x($[e.kind])]}):null]},`${e.kind}:${e.expiresAt}`))}):null]}),(0,G.jsxs)(`div`,{className:`flex items-start gap-2.5 py-5 text-[14px] text-ink-2 leading-snug last:pb-0`,children:[(0,G.jsx)(S,{className:`mt-0.5 size-4 shrink-0 text-cobalt`}),(0,G.jsx)(`p`,{children:x(`account.cloud`,{host:D(e.cloudUrl)})})]})]})}function re({me:e,fromAccount:t}){let n=o(),[r,i]=(0,L.useState)(e.profile),s=e=>i(t=>({...t,...e})),c=U(r,async e=>{await a.put(`/api/studio/profile`,e),await n.invalidateQueries({queryKey:[`me`]})});return(0,G.jsx)(K,{title:x(`account.profile`),hint:x(`account.hint`),save:c,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-6 sm:flex-row sm:gap-8`,children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-2 sm:w-32`,children:[(0,G.jsx)(`div`,{className:`flex size-20 items-center justify-center overflow-hidden rounded-full bg-ember-tint font-semibold text-[28px] text-ember-strong ring-1 ring-border-soft`,children:e.user.image?(0,G.jsx)(`img`,{src:e.user.image,alt:``,className:`size-full object-cover`}):T(r.name)||`?`}),(0,G.jsx)(`p`,{className:`text-center text-[12px] text-ink-3 leading-snug`,children:x(`account.initials`)})]}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(p,{children:x(`account.name`)}),(0,G.jsx)(y,{value:r.name,maxLength:80,disabled:t,onChange:e=>s({name:e.target.value})}),(0,G.jsx)(`p`,{className:X,children:x(t?`account.fromAccount`:`account.nameHint`)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(p,{children:x(`account.about`)}),(0,G.jsx)(g,{minRows:3,maxLength:2e3,value:r.about,onChange:e=>s({about:e.target.value})}),(0,G.jsx)(`p`,{className:X,children:x(`account.aboutHint`)})]}),(0,G.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(p,{children:x(`account.email`)}),(0,G.jsx)(y,{type:`email`,value:r.email,maxLength:200,disabled:t,onChange:e=>s({email:e.target.value})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(p,{children:x(`account.phone`)}),(0,G.jsx)(y,{type:`tel`,value:r.phone,maxLength:40,onChange:e=>s({phone:e.target.value})})]})]})]})]})})}function ie({me:e}){let t=e.mode===`managed`,n=t||!!e.account;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-9`,children:[(0,G.jsx)(K,{title:x(`account.connection`),hint:x(`account.connectionHint`),children:t?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate font-medium text-[15px]`,children:e.user.name}),(0,G.jsx)(v,{tone:`live`,children:x(`account.linked`)})]}),(0,G.jsx)(`div`,{className:`truncate text-[14px] text-ink-3`,children:e.user.email})]}),e.manageUrl?(0,G.jsxs)(b,{variant:`secondary`,onClick:()=>A(`${e.manageUrl}/account`),children:[x(`setup.openAccount`),` `,(0,G.jsx)(d,{className:`size-4`})]}):null]}):e.account?(0,G.jsx)(ne,{account:e.account}):(0,G.jsx)(te,{})}),(0,G.jsx)(re,{me:e,fromAccount:n},n?`account`:`own`),(0,G.jsx)(K,{title:x(`account.look`),hint:x(`account.lookHint`),children:(0,G.jsxs)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pb-4`,children:[(0,G.jsx)(`span`,{className:`font-medium text-[14px]`,children:x(`nav.language`)}),(0,G.jsx)(E,{tone:`surface`})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 pt-4`,children:[(0,G.jsx)(`span`,{className:`font-medium text-[14px]`,children:x(`nav.theme`)}),(0,G.jsx)(k,{})]})]})})]})}export{q as a,W as c,V as d,H as f,Y as i,B as l,Q as n,J as o,z as p,Z as r,K as s,ie as t,U as u};
@@ -1,2 +0,0 @@
1
- import{a as e,n as t,t as n}from"./jsx-runtime-D3jfb0Ew.js";import{D as r,O as i,d as a,i as o,j as s,n as c,nt as l}from"./api-u3nydnnp.js";import{t as u}from"./createLucideIcon-q3MZMmnf.js";import{n as d}from"./HomePage-BdIa2zcg.js";import{C as f,T as p,b as m,r as h,w as g,x as _}from"./outputs-s8BpXH6V.js";import{t as v}from"./check-CUpby_J9.js";import{r as ee,t as te}from"./ChatPanel-CtE1wcUD.js";import{t as y}from"./upload-DNRENWzQ.js";import{t as b}from"./plus-Du-Jx8aI.js";import{t as ne}from"./external-link-MAL7vJYj.js";import{n as x,t as re}from"./wand-sparkles-Clj3VRB5.js";import{n as ie}from"./mic-Bvz4mA2j.js";import{a as ae,c as S,d as C,f as w,i as T,l as E,o as D,p as oe,s as O,u as k}from"./Account-YJEQEo5k.js";import{n as se,t as A}from"./trash-0IafyhZB.js";import{t as ce}from"./refresh-cw-Cmk7VCe0.js";import{n as le,t as ue}from"./type-BqbppSsp.js";import{_ as de,a as fe,c as j,d as M,f as pe,h as N,i as P,m as F,o as I,p as me,r as L,s as R,t as z,u as he,y as B}from"./ui-gGAdXx-P.js";import{F as V,b as ge,x as _e}from"./index-BAQ2e4is.js";import{n as ve,t as ye}from"./ReadOnly-B0-ReU_0.js";var H={name:`calendar`,size:24,node:[[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,key:`h1oib`}],[`path`,{d:`M3 9h18`,key:`1pudct`}]]};H.node;var be=u(H),xe={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};xe.node;var Se=u(xe),Ce={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};Ce.node;var we=u(Ce),Te={name:`music`,size:24,node:[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]};Te.node;var Ee=u(Te),De={name:`phone`,size:24,node:[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]};De.node;var Oe=u(De),ke={name:`text-align-start`,size:24,node:[[`path`,{d:`M21 5H3`,key:`1fi0y6`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M17 19H3`,key:`z6ezky`}]],aliases:[`text`,`align-left`]};ke.node;var Ae=u(ke),je={name:`toggle-left`,size:24,node:[[`circle`,{cx:`9`,cy:`12`,r:`3`,key:`u3jwor`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`7`,key:`g7kal2`}]]};je.node;var Me=u(je),U=e(t(),1),W=e(n(),1);function Ne(e){return e.type.startsWith(`image/`)&&/logo/i.test(e.name)?`logo`:/^(image|video|audio)\//.test(e.type)?`asset`:`document`}function Pe(e,t){let n=l(),[r,i]=(0,U.useState)([]),[a,s]=(0,U.useState)(`idle`),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(null),[m,h]=(0,U.useState)(null),g=(0,U.useRef)(null),_=()=>(g.current??=(async()=>{await Promise.all([n.invalidateQueries({queryKey:[`projects`]}),n.invalidateQueries({queryKey:[`project-files`,e]})]),t(),g.current=null})(),g.current);return{messages:r,phase:a,activity:f,startedAt:m,error:u,send:async(t,l=[])=>{if(!(t.trim()||l.length)||a!==`idle`)return!1;if(d(null),s(`thinking`),h(Date.now()),l.length){try{for(let t of l)await c.upload(`/api/studio/projects/${e}/files?kind=${Ne(t)}`,t)}catch(e){return d(e.message),s(`idle`),h(null),await _(),!1}await _();let n=`${B(`editor.attached`)}: ${l.map(e=>e.name).join(`, `)}`;t=t.trim()?`${t}\n\n${n}`:n}let u=r.map(({role:e,content:t})=>({role:e,content:t})).slice(-12),f=`p-${Date.now()}`;i(e=>[...e,{id:`u-${Date.now()}`,role:`user`,content:t,previews:ee(l)},{id:f,role:`assistant`,content:``,pending:!0}]),p(null);let m=!1;try{await o(`/api/studio/projects/${e}/assist`,{message:t,history:u},(e,t)=>{if(e===`text`){let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:t.content+e}:t))}else if(e===`activity`)p(JSON.parse(t));else if(e===`changed`)s(`building`),_();else if(e===`done`){m=!0;let e=JSON.parse(t);i(t=>t.map(t=>t.id===f?{...t,content:e.reply,changed:e.changed,pending:!1}:t))}else e===`error`&&(m=!0,d(JSON.parse(t).message))}),m||d(B(`editor.chatBroken`))}catch(e){d(e.message)}finally{p(null),h(null),i(e=>e.filter(e=>!(e.id===f&&!e.content)).map(e=>({...e,pending:!1}))),s(`idle`),await g.current,await _(),await n.invalidateQueries({queryKey:[`me`]})}return!0}}}function Fe(){return(0,W.jsxs)(`div`,{className:`sm:pr-36`,children:[(0,W.jsx)(`h2`,{className:`font-display font-semibold text-[20px] leading-tight tracking-tight`,children:B(`project.assistantTitle`)}),(0,W.jsx)(`p`,{className:`mt-1.5 max-w-2xl text-[15px] text-ink-2 leading-relaxed`,children:B(`project.assistantHello`)})]})}var Ie=72,Le=720;function Re({projectId:e,onChanged:t}){let n=Pe(e,t),r=(0,U.useRef)(null),[i,o]=(0,U.useState)(null);return(0,U.useEffect)(()=>{let e=()=>{let e=r.current?.getBoundingClientRect();e&&o(t=>{if(e.bottom>=Ie)return null;let n=Math.min(e.width,Le),r=e.left+(e.width-n)/2;return t&&t.left===r&&t.width===n?t:{left:r,width:n,height:t?.height??e.height}})};return e(),window.addEventListener(`scroll`,e,{passive:!0}),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`scroll`,e),window.removeEventListener(`resize`,e)}},[]),(0,W.jsxs)(`div`,{ref:r,style:i?{minHeight:i.height}:void 0,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 px-1 font-medium text-[12px] text-ember-strong uppercase tracking-[0.07em]`,children:[(0,W.jsx)(m,{className:`size-3.5`}),` `,B(`project.assistant`)]}),(0,W.jsxs)(`div`,{className:`relative`,children:[!i&&n.messages.length===0?(0,W.jsx)(`div`,{className:`absolute -top-14 right-10 z-10 max-sm:hidden`,children:(0,W.jsx)(a,{kind:`round`,size:104})}):null,(0,W.jsx)(`div`,{className:N(`flex flex-col overflow-hidden bg-card`,i?`fixed bottom-4 z-30 max-h-[70dvh] animate-dock rounded-2xl shadow-overlay ring-1 ring-border`:`max-h-[520px] rounded-xl bg-linear-to-br from-ember-tint via-card to-card shadow-soft ring-1 ring-ember-veil`),style:i?{left:i.left,width:i.width}:void 0,children:(0,W.jsx)(te,{chat:n,avatar:`round`,compact:!!i,intro:(0,W.jsx)(Fe,{}),placeholder:B(`project.assistantComposer`),changedLabel:B(`project.assistantChanged`)})})]})]})}var ze=[`text`,`longtext`,`number`,`date`,`url`,`email`,`phone`,`boolean`],Be=/^(\d{4}-\d{2}-\d{2}|\d{1,2}\.\s?\d{1,2}\.\s?\d{4})$/,Ve=/^[+-]?\d{1,3}([.,\s']?\d{3})*([.,]\d+)?$/,He=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,Ue=/^(https?:\/\/|www\.)\S+$/i,We=/^\+?[\d\s()/.-]{7,20}$/,Ge=/^(ja|nein|yes|no|true|false)$/i;function Ke(e){let t=e.trim();return t?t.includes(`
2
- `)||t.length>140?`longtext`:Ge.test(t)?`boolean`:He.test(t)?`email`:Ue.test(t)?`url`:Be.test(t)?`date`:Ve.test(t)&&!/^(\+|0\d)/.test(t)?`number`:We.test(t)&&t.replace(/\D/g,``).length>=7?`phone`:`text`:`text`}function qe(e,t=[]){let n=e.toLowerCase().replace(/ä/g,`ae`).replace(/ö/g,`oe`).replace(/ü/g,`ue`).replace(/ß/g,`ss`).normalize(`NFD`).replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,40)||`fakt`,r=n;for(let e=2;t.includes(r);e++)r=`${n}_${e}`;return r}var Je=[{key:`adresse`,de:`Adresse`,en:`Address`},{key:`plz`,de:`PLZ`,en:`Postcode`},{key:`ort`,de:`Ort`,en:`City`},{key:`uid`,de:`UID`,en:`VAT id`},{key:`telefon`,de:`Telefon`,en:`Phone`},{key:`e_mail`,de:`E-Mail`,en:`Email`},{key:`website`,de:`Website`,en:`Website`},{key:`iban`,de:`IBAN`,en:`IBAN`}],G={facts:100,colors:12,files:{logo:8,asset:100,document:50},bytes:{logo:5e6,asset:15e6,video:8e7,document:3e7}},K=/^#[0-9a-fA-F]{6}$/;function Ye({onAdd:e,onClose:t}){let[n,r]=(0,U.useState)(`#e0531b`),[i,a]=(0,U.useState)(``),o=K.test(n);return(0,W.jsx)(P,{open:!0,onClose:t,title:B(`project.colorAddTitle`),children:(0,W.jsxs)(`form`,{onSubmit:r=>{r.preventDefault(),o&&(e({name:i.trim(),value:n.toLowerCase()}),t())},className:`flex flex-col gap-5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(j,{children:B(`project.colorValue`)}),(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(pe,{value:o?n:`#888888`,onChange:e=>r(e.target.value)}),(0,W.jsx)(R,{value:n,placeholder:`#e0531b`,spellCheck:!1,onChange:e=>r(e.target.value.trim()),className:`font-mono text-[14px]`})]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(j,{children:B(`project.colorUseLabel`)}),(0,W.jsx)(R,{autoFocus:!0,value:i,maxLength:120,placeholder:B(`project.colorName`),onChange:e=>a(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:B(`project.colorUse`)})]}),(0,W.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,W.jsx)(z,{variant:`ghost`,onClick:t,children:B(`common.cancel`)}),(0,W.jsx)(z,{type:`submit`,disabled:!o,children:B(`project.add`)})]})]})})}function Xe({colors:e,save:t,readOnly:n}){let r=(0,U.useRef)(0),[i,a]=(0,U.useState)(()=>e.map(e=>({...e,id:`c${r.current++}`}))),[o,s]=(0,U.useState)(!1),c=k(i.filter(e=>K.test(e.value)).map(({name:e,value:t})=>({name:e.trim(),value:t})),t),l=(e,t)=>a(n=>n.map(n=>n.id===e?{...n,...t}:n));return(0,W.jsxs)(O,{title:B(`project.colors`),hint:B(`project.colorsHint`),save:c,locked:n,children:[(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:i.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(pe,{value:K.test(e.value)?e.value:`#888888`,onChange:t=>l(e.id,{value:t.target.value})}),(0,W.jsx)(R,{value:e.name,placeholder:B(`project.colorName`),maxLength:120,onChange:t=>l(e.id,{name:t.target.value}),className:`min-w-0 flex-1`}),(0,W.jsx)(R,{value:e.value,placeholder:`#e0531b`,spellCheck:!1,onChange:t=>l(e.id,{value:t.target.value.trim()}),className:`w-28 font-mono text-[13px]`}),(0,W.jsxs)(`div`,{className:`flex w-24 shrink-0 items-center justify-end max-sm:w-auto`,children:[t===0?(0,W.jsx)(`span`,{className:`mr-1 max-sm:hidden`,children:(0,W.jsx)(L,{tone:`ember`,children:B(`project.colorAccent`)})}):n?null:(0,W.jsx)(I,{label:B(`project.colorFirst`),onClick:()=>a(t=>[e,...t.filter(t=>t.id!==e.id)]),children:(0,W.jsx)(p,{className:`size-4`})}),n?null:(0,W.jsx)(I,{label:B(`project.remove`),onClick:()=>a(t=>t.filter(t=>t.id!==e.id)),className:`hover:text-rose`,children:(0,W.jsx)(A,{className:`size-4`})})]})]},e.id))}),i.length&&!n?(0,W.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:B(`project.colorUse`)}):null,i.length<G.colors&&!n?(0,W.jsxs)(z,{variant:`secondary`,size:`sm`,className:i.length?`mt-3`:void 0,onClick:()=>s(!0),children:[(0,W.jsx)(b,{className:`size-4`}),` `,B(`project.colorAdd`)]}):null,o?(0,W.jsx)(Ye,{onClose:()=>s(!1),onAdd:e=>a(t=>[...t,{...e,id:`c${r.current++}`}])}):null]})}var Ze={backgroundImage:`repeating-conic-gradient(#c9c9c9 0% 25%, #dedede 0% 50%)`,backgroundSize:`16px 16px`};function q({file:e,actions:t}){let[n,r]=(0,U.useState)(e.description),i=(0,U.useRef)(e.description),a=(0,U.useRef)(null);(0,U.useEffect)(()=>{e.description!==i.current&&(r(t=>t===i.current?e.description:t),i.current=e.description)},[e.description]),(0,U.useLayoutEffect)(()=>{let e=a.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)},[n]);let o=e.status===`pending`&&!n;return t.readOnly?n?(0,W.jsx)(`p`,{className:`text-[13px] text-ink-2 leading-snug`,children:n}):null:(0,W.jsx)(`textarea`,{ref:a,rows:1,value:n,maxLength:600,placeholder:B(o?`project.describing`:`project.description`),onChange:e=>r(e.target.value),onBlur:()=>{n.trim()!==e.description&&(i.current=n.trim(),t.describe(e.id,n.trim()))},className:`-mx-1 block w-[calc(100%+0.5rem)] resize-none overflow-hidden rounded-md bg-transparent px-1 py-0.5 text-[13px] text-ink-2 leading-snug outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`})}function J(e,t){confirm(B(`project.removeConfirm`,{name:e.name}))&&t.remove(e.id)}function Y({projectId:e,file:t,small:n}){let r=E(e,t.id);return t.mime.startsWith(`image/`)?(0,W.jsx)(`img`,{src:r,alt:``,loading:`lazy`,className:N(`size-full`,t.kind===`logo`?`object-contain p-3`:`object-cover`)}):t.mime.startsWith(`video/`)?(0,W.jsx)(`video`,{src:`${r}#t=0.1`,preload:`metadata`,controls:!n,className:`size-full object-cover`}):(0,W.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-3`,children:t.mime.startsWith(`audio/`)?(0,W.jsx)(Ee,{className:n?`size-5`:`size-7`}):(0,W.jsx)(g,{className:n?`size-5`:`size-7`})})}function Qe({projectId:e,kind:t,files:n,actions:r,accept:i,addLabel:a,onPreview:o}){return(0,W.jsxs)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(184px,1fr))] gap-3`,children:[n.map((i,a)=>(0,W.jsxs)(`div`,{className:`group relative flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[t===`logo`&&a===0?(0,W.jsx)(`span`,{className:`absolute -top-3 left-3 z-10 rounded-full ring-2 ring-card`,children:(0,W.jsx)(L,{tone:`ember`,children:B(`project.logoMain`)})}):null,(0,W.jsxs)(`div`,{className:`relative h-28 overflow-hidden rounded-md bg-paper-2`,style:t===`logo`?Ze:void 0,children:[o&&i.mime.startsWith(`image/`)?(0,W.jsx)(`button`,{type:`button`,"aria-label":`${B(`project.preview`)}: ${i.name}`,onClick:()=>o(i),className:`block size-full cursor-zoom-in`,children:(0,W.jsx)(Y,{projectId:e,file:i})}):(0,W.jsx)(Y,{projectId:e,file:i}),(0,W.jsxs)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100`,children:[o?(0,W.jsx)(I,{label:B(`project.preview`),onClick:()=>o(i),className:`size-8 bg-card shadow-soft`,children:(0,W.jsx)(x,{className:`size-4`})}):null,t===`logo`&&a>0&&!r.readOnly?(0,W.jsx)(I,{label:B(`project.logoMakeMain`),onClick:()=>r.order(`logo`,[i.id,...n.filter(e=>e.id!==i.id).map(e=>e.id)]),className:`size-8 bg-card shadow-soft`,children:(0,W.jsx)(le,{className:`size-4`})}):null,r.readOnly?null:(0,W.jsx)(I,{label:B(`project.remove`),onClick:()=>J(i,r),className:`size-8 bg-card shadow-soft hover:text-rose`,children:(0,W.jsx)(A,{className:`size-4`})})]})]}),t===`asset`?(0,W.jsx)(`div`,{className:`truncate px-0.5 text-[12px] text-ink-3`,title:i.name,children:i.name}):null,(0,W.jsx)(q,{file:i,actions:r})]},i.id)),a&&!r.readOnly?(0,W.jsxs)(T,{accept:i,multiple:!1,onFiles:e=>r.upload(t,e),className:`min-h-28 flex-col p-3`,children:[r.busy?(0,W.jsx)(M,{className:`size-5`}):(0,W.jsx)(b,{className:`size-5`}),a]}):null]})}function $e({projectId:e,data:t,readOnly:n}){let r=C(e,n);return(0,W.jsxs)(O,{title:B(`project.logos`),hint:B(`project.logosHint`),children:[(0,W.jsx)(Qe,{projectId:e,kind:`logo`,files:t.files.filter(e=>e.kind===`logo`),actions:r,accept:`image/*`,addLabel:B(`project.logoAdd`)}),r.error?(0,W.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:r.error}):null]})}var et=e=>[(e.name.includes(`.`)?e.name.split(`.`).pop():e.mime.split(`/`).pop())?.toUpperCase().slice(0,5),S(e.size)].filter(Boolean).join(` · `);function tt({projectId:e,file:t,actions:n,onClose:r}){let i=E(e,t.id);return(0,W.jsxs)(P,{open:!0,onClose:r,wide:`page`,title:t.name,children:[(0,W.jsxs)(`div`,{className:`-mt-2 mb-4 flex items-center justify-between gap-3`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-ink-3`,children:et(t)}),(0,W.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,"aria-label":B(`project.openOriginal`),title:B(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,W.jsx)(ne,{className:`size-4`})})]}),t.mime.startsWith(`image/`)?(0,W.jsx)(`div`,{className:`overflow-hidden rounded-lg`,style:Ze,children:(0,W.jsx)(`img`,{src:i,alt:``,className:`mx-auto max-h-[68dvh] object-contain`})}):t.mime.startsWith(`video/`)?(0,W.jsx)(`video`,{src:i,controls:!0,className:`max-h-[68dvh] w-full rounded-lg bg-black`}):(0,W.jsx)(`audio`,{src:i,controls:!0,className:`w-full`}),(0,W.jsx)(`div`,{className:`mt-4`,children:(0,W.jsx)(q,{file:t,actions:n})})]})}function nt({projectId:e,file:t,actions:n,onPreview:r}){return(0,W.jsxs)(`li`,{className:`flex items-start gap-3 rounded-lg bg-paper p-2 ring-1 ring-border-soft`,children:[(0,W.jsx)(`button`,{type:`button`,"aria-label":`${B(`project.preview`)}: ${t.name}`,onClick:r,className:`size-14 shrink-0 cursor-zoom-in overflow-hidden rounded-md bg-paper-2`,children:(0,W.jsx)(Y,{projectId:e,file:t,small:!0})}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1 py-0.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-3`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:r,title:t.name,className:`min-w-0 truncate font-medium text-[14px] hover:underline`,children:t.name}),(0,W.jsx)(`span`,{className:`text-[12px] text-ink-3`,children:et(t)})]}),(0,W.jsx)(q,{file:t,actions:n})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start`,children:[(0,W.jsx)(I,{label:B(`project.preview`),onClick:r,children:(0,W.jsx)(x,{className:`size-4`})}),n.readOnly?null:(0,W.jsx)(I,{label:B(`project.remove`),onClick:()=>J(t,n),className:`hover:text-rose`,children:(0,W.jsx)(A,{className:`size-4`})})]})]})}function rt({projectId:e,data:t,readOnly:n}){let r=C(e,n),[i,a]=w(`assets`,`cards`),[o,s]=(0,U.useState)(``),[c,l]=(0,U.useState)(null),u=t.files.filter(e=>e.kind===`asset`),d=u.find(e=>e.id===c),f=o.trim().toLowerCase(),p=f?u.filter(e=>`${e.name} ${e.description}`.toLowerCase().includes(f)):u;return(0,W.jsxs)(O,{title:B(`project.assets`),hint:B(`project.assetsHint`),children:[u.length?(0,W.jsx)(ae,{layout:i,onToggle:a,children:(0,W.jsx)(D,{value:o,onChange:s,placeholder:B(`project.assetSearch`)})}):null,p.length?(0,W.jsx)(`div`,{className:`mb-3`,children:i===`cards`?(0,W.jsx)(Qe,{projectId:e,kind:`asset`,files:p,actions:r,onPreview:e=>l(e.id)}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,children:p.map(t=>(0,W.jsx)(nt,{projectId:e,file:t,actions:r,onPreview:()=>l(t.id)},t.id))})}):null,n?u.length?null:(0,W.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:B(`project.staysLocal`)}):(0,W.jsxs)(T,{accept:`image/*,video/*,audio/*`,onFiles:e=>r.upload(`asset`,e),className:`h-16 w-full`,children:[r.busy?(0,W.jsx)(M,{className:`size-4`}):(0,W.jsx)(y,{className:`size-4`}),B(`project.drop`),` `,(0,W.jsx)(`span`,{className:`underline`,children:B(`project.assetAdd`)})]}),r.error?(0,W.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:r.error}):null,d?(0,W.jsx)(tt,{projectId:e,file:d,actions:r,onClose:()=>l(null)}):null]})}function it(e,t,n){return s({queryKey:[`project-file-text`,t.id,t.chars,n],queryFn:()=>c.get(`/api/studio/projects/${e}/files/${t.id}/text?limit=${n}`),enabled:t.status===`ready`,staleTime:6e4})}function at(e){return((e.name.includes(`.`)?e.name.split(`.`).pop():``)||e.mime.split(`/`).pop()||``).toUpperCase().slice(0,5)}var X=e=>[at(e),e.pages?B(`project.pages`,{n:e.pages}):null,S(e.size)].filter(Boolean).join(` · `);function Z({file:e}){return e.status===`pending`?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[12px] text-ink-3`,children:[(0,W.jsx)(M,{className:`size-3`}),` `,B(`project.reading`)]}):e.status===`failed`?(0,W.jsx)(`span`,{className:`text-[12px] text-rose`,children:e.error}):e.indexed?(0,W.jsx)(L,{tone:`live`,children:e.indexed===`embeddings`?B(`project.indexed`):B(`project.indexedKeywords`)}):(0,W.jsx)(L,{tone:`warn`,children:B(`project.notIndexed`)})}function ot({file:e,actions:t,onPreview:n}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(I,{label:B(`project.preview`),onClick:n,children:(0,W.jsx)(x,{className:`size-4`})}),e.status!==`pending`&&!t.readOnly?(0,W.jsx)(I,{label:B(`project.reindex`),onClick:()=>t.reindex(e.id),children:(0,W.jsx)(ce,{className:`size-4`})}):null,t.readOnly?null:(0,W.jsx)(I,{label:B(`project.remove`),onClick:()=>J(e,t),className:`hover:text-rose`,children:(0,W.jsx)(A,{className:`size-4`})})]})}function st({file:e,actions:t,onPreview:n}){let r=/sheet|csv|excel/.test(e.mime);return(0,W.jsxs)(`li`,{className:`flex gap-3 rounded-lg bg-paper p-3 ring-1 ring-border-soft`,children:[(0,W.jsx)(`div`,{className:`mt-0.5 text-ink-3`,children:r?(0,W.jsx)(Se,{className:`size-5`}):(0,W.jsx)(ie,{className:`size-5`})}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:n,title:e.name,className:`min-w-0 truncate font-medium text-[14px] hover:underline`,children:e.name}),(0,W.jsx)(`span`,{className:`text-[12px] text-ink-3`,children:X(e)}),(0,W.jsx)(Z,{file:e})]}),(0,W.jsx)(q,{file:e,actions:t})]}),(0,W.jsx)(`div`,{className:`-my-1 flex shrink-0 items-start`,children:(0,W.jsx)(ot,{file:e,actions:t,onPreview:n})})]})}function ct({projectId:e,file:t}){let n=it(e,t,1500);return t.mime.startsWith(`image/`)?(0,W.jsx)(`img`,{src:E(e,t.id),alt:``,className:`size-full object-cover`}):t.status===`pending`||n.isLoading?(0,W.jsx)(`div`,{className:`flex size-full items-center justify-center text-ink-4`,children:(0,W.jsx)(M,{className:`size-5`})}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`w-[222%] origin-top-left scale-[0.45] p-6`,children:(0,W.jsx)(h,{text:n.data?.text??``})}),(0,W.jsx)(`div`,{className:`absolute inset-x-0 bottom-0 h-12 bg-linear-to-t from-card to-transparent`})]})}function lt({projectId:e,file:t,actions:n,onPreview:r}){return(0,W.jsxs)(`li`,{className:`group flex flex-col gap-1.5 rounded-lg bg-paper p-2 pb-2.5 ring-1 ring-border-soft`,children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`${B(`project.preview`)}: ${t.name}`,className:`relative block h-44 w-full overflow-hidden rounded-md bg-card text-left ring-1 ring-border-soft transition hover:ring-border`,children:(0,W.jsx)(ct,{projectId:e,file:t})}),(0,W.jsx)(`div`,{className:`absolute top-1 right-1 flex gap-1 opacity-0 transition focus-within:opacity-100 group-hover:opacity-100 coarse:opacity-100 [&>button]:size-8 [&>button]:bg-card [&>button]:shadow-soft`,children:(0,W.jsx)(ot,{file:t,actions:n,onPreview:r})})]}),(0,W.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1 px-0.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-medium text-[13px]`,title:t.name,children:t.name}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,W.jsx)(`span`,{className:`text-[12px] text-ink-3`,children:X(t)}),(0,W.jsx)(Z,{file:t})]})]}),(0,W.jsx)(q,{file:t,actions:n})]})}var ut=2e5;function dt({projectId:e,file:t,onClose:n}){let r=t.mime===`application/pdf`||t.mime.startsWith(`image/`),[i,a]=(0,U.useState)(r?`original`:`text`),o=it(e,t,ut),s=E(e,t.id),c=(e,t)=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":i===e,onClick:()=>a(e),className:N(`h-8 rounded-full px-3 text-[13px] transition`,i===e?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:text-ink`),children:t});return(0,W.jsxs)(P,{open:!0,onClose:n,wide:`page`,title:t.name,children:[(0,W.jsxs)(`div`,{className:`-mt-2 mb-4 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,W.jsx)(`span`,{className:`text-[13px] text-ink-3`,children:X(t)}),(0,W.jsx)(Z,{file:t}),(0,W.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[r?(0,W.jsxs)(W.Fragment,{children:[c(`original`,B(`project.original`)),c(`text`,B(`project.readText`))]}):null,(0,W.jsx)(`a`,{href:s,target:`_blank`,rel:`noreferrer`,"aria-label":B(`project.openOriginal`),title:B(`project.openOriginal`),className:`inline-flex size-9 items-center justify-center rounded-full text-ink-3 transition hover:bg-accent hover:text-ink`,children:(0,W.jsx)(ne,{className:`size-4`})})]})]}),i===`original`?t.mime===`application/pdf`?(0,W.jsx)(`iframe`,{src:s,title:t.name,className:`h-[70dvh] w-full rounded-lg bg-paper-2 ring-1 ring-border-soft`}):(0,W.jsx)(`img`,{src:s,alt:``,className:`mx-auto max-h-[70dvh] rounded-lg object-contain`}):o.isLoading?(0,W.jsx)(`div`,{className:`flex h-40 items-center justify-center text-ink-3`,children:(0,W.jsx)(M,{})}):o.data?.text?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`overflow-x-auto rounded-lg bg-paper p-5 ring-1 ring-border-soft`,children:(0,W.jsx)(h,{text:o.data.text,className:`text-[14px]`})}),o.data.chars>o.data.text.length?(0,W.jsx)(`p`,{className:`mt-3 text-[13px] text-ink-3`,children:B(`project.textCut`,{shown:o.data.text.length.toLocaleString(),total:o.data.chars.toLocaleString()})}):null]}):(0,W.jsx)(`p`,{className:`py-8 text-center text-[14px] text-ink-3`,children:B(`project.noText`)})]})}function ft({projectId:e}){let[t,n]=(0,U.useState)(``),[r,i]=(0,U.useState)(null),[a,o]=(0,U.useState)(!1),s=async()=>{if(!t.trim()){i(null);return}o(!0);try{let n=await c.post(`/api/studio/projects/${e}/search`,{query:t});i(n.hits)}catch{i([])}finally{o(!1)}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(D,{value:t,placeholder:B(`project.searchTest`),busy:a,onEnter:()=>void s(),onChange:e=>{n(e),e.trim()||i(null)}}),r?r.length?(0,W.jsx)(`ul`,{className:`mt-2 flex flex-col gap-2`,children:r.map((e,t)=>(0,W.jsxs)(`li`,{className:`rounded-lg bg-paper-2 px-3 py-2 text-[13px]`,children:[(0,W.jsx)(`div`,{className:`mb-0.5 font-medium text-[12px] text-ink-3`,children:e.name}),(0,W.jsx)(`p`,{className:`line-clamp-3 whitespace-pre-line text-ink-2`,children:e.text})]},t))}):(0,W.jsx)(`p`,{className:`mt-2 text-[13px] text-ink-3`,children:B(`project.searchNone`)}):null]})}function pt({projectId:e,data:t,readOnly:n}){let r=C(e,n),[i,a]=w(`documents`,`list`),[o,s]=(0,U.useState)(null),c=t.files.filter(e=>e.kind===`document`),l=c.find(e=>e.id===o),u=i===`cards`?lt:st;return(0,W.jsxs)(O,{title:B(`project.documents`),hint:B(`project.documentsHint`),children:[c.length?(0,W.jsx)(ae,{layout:i,onToggle:a,children:(0,W.jsx)(ft,{projectId:e})}):null,c.length?(0,W.jsx)(`ul`,{className:N(`mb-3`,i===`cards`?`grid grid-cols-[repeat(auto-fill,minmax(220px,1fr))] gap-3`:`flex flex-col gap-2`),children:c.map(t=>(0,W.jsx)(u,{projectId:e,file:t,actions:r,onPreview:()=>s(t.id)},t.id))}):null,n?c.length?null:(0,W.jsx)(`p`,{className:`text-[14px] text-ink-3`,children:B(`project.staysLocal`)}):(0,W.jsxs)(T,{accept:`.pdf,.docx,.doc,.xlsx,.csv,.tsv,.txt,.md,.json,.html,.eml,image/*`,onFiles:e=>r.upload(`document`,e),className:`h-16 w-full`,children:[r.busy?(0,W.jsx)(M,{className:`size-4`}):(0,W.jsx)(y,{className:`size-4`}),B(`project.drop`),` `,(0,W.jsx)(`span`,{className:`underline`,children:B(`project.documentAdd`)})]}),r.error?(0,W.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:r.error}):null,c.length&&!t.embeddings?(0,W.jsx)(`p`,{className:`mt-3 text-[13px] text-ink-3`,children:B(`project.keywordsOnly`)}):null,l?(0,W.jsx)(dt,{projectId:e,file:l,onClose:()=>s(null)}):null]})}var Q=e=>/^(ja|yes|true)$/i.test(e.trim()),mt={text:ue,longtext:Ae,number:we,date:be,url:se,email:f,phone:Oe,boolean:Me};function ht({type:e,detected:t,onChange:n}){let[r,i]=(0,U.useState)(!1),[a,o]=(0,U.useState)(!1),s=(0,U.useRef)(null);(0,U.useEffect)(()=>{if(!r)return;let e=e=>{s.current?.contains(e.target)||i(!1)},t=e=>e.key===`Escape`&&i(!1);return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[r]);let c=mt[e??t],l=`${B(`project.factType`)}: ${B(`project.type.${e??t}`)}`,u=`flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-[14px] text-ink-2 hover:bg-accent hover:text-ink`,d=e=>{n(e),i(!1)};return(0,W.jsxs)(`div`,{className:`relative`,ref:s,children:[(0,W.jsx)(`button`,{type:`button`,"aria-label":l,title:l,"aria-haspopup":`menu`,"aria-expanded":r,onClick:e=>{o(window.innerHeight-e.currentTarget.getBoundingClientRect().bottom<400),i(e=>!e)},className:N(`inline-flex size-11 items-center justify-center rounded-lg transition hover:bg-accent hover:text-ink`,r?`bg-accent text-ink`:e?`text-ink-2`:`text-ink-4`),children:(0,W.jsx)(c,{className:`size-4`})}),r?(0,W.jsxs)(`div`,{role:`menu`,className:N(`absolute right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,a?`bottom-12`:`top-12`),children:[(0,W.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":!e,className:u,onClick:()=>d(void 0),children:[(0,W.jsx)(re,{className:`size-4 shrink-0`}),(0,W.jsx)(`span`,{className:`flex-1`,children:B(`project.factAuto`)}),(0,W.jsx)(`span`,{className:`text-[12px] text-ink-4`,children:B(`project.type.${t}`)}),(0,W.jsx)(v,{className:N(`size-4 shrink-0`,e&&`invisible`)})]}),(0,W.jsx)(`div`,{className:`mx-2 my-1 h-px bg-border-soft`}),ze.map(t=>{let n=mt[t];return(0,W.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===t,className:u,onClick:()=>d(t),children:[(0,W.jsx)(n,{className:`size-4 shrink-0`}),(0,W.jsx)(`span`,{className:`flex-1`,children:B(`project.type.${t}`)}),(0,W.jsx)(v,{className:N(`size-4 shrink-0`,e!==t&&`invisible`)})]},t)})]}):null]})}function gt({facts:e,save:t,readOnly:n}){let r=(0,U.useRef)(0),i=(0,U.useRef)(null),[a,o]=(0,U.useState)(()=>e.map(e=>({...e,id:`f${r.current++}`}))),s=k(a.filter(e=>e.key&&e.label.trim()).map(({key:e,label:t,value:n,type:r})=>({key:e,label:t.trim(),value:n,...r?{type:r}:{}})),t),c=(e,t)=>o(n=>n.map(n=>n.id===e?{...n,...t}:n)),l=(e,t,n=!1)=>{let a=`f${r.current++}`;i.current=`${a}:${t}`;let s={id:a,key:``,label:``,value:``,...e};o(e=>n?[s,...e]:[...e,s])},u=e=>t=>{t&&i.current===e&&(i.current=null,t.focus())},d=Je.filter(e=>!a.some(t=>t.key===e.key));return(0,W.jsxs)(O,{title:B(`project.facts`),hint:B(`project.factsHint`),save:s,locked:n,action:a.length<G.facts&&!n?(0,W.jsxs)(z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`,!0),children:[(0,W.jsx)(b,{className:`size-4`}),` `,B(`project.factAdd`)]}):null,children:[(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>{let t=Ke(e.value),r=e.type??t;return(0,W.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] items-start gap-x-1 gap-y-2 sm:grid-cols-[minmax(0,2fr)_minmax(0,3fr)_auto_auto]`,children:[(0,W.jsx)(R,{ref:u(`${e.id}:label`),value:e.label,placeholder:B(`project.factLabel`),title:e.key?`{{facts.${e.key}}}`:void 0,onChange:t=>c(e.id,{label:t.target.value}),onBlur:()=>{!e.key&&e.label.trim()&&c(e.id,{key:qe(e.label,a.map(e=>e.key))})},className:`max-sm:col-span-3 max-sm:font-medium sm:mr-1`}),e.type===`boolean`?(0,W.jsxs)(`div`,{className:`flex h-11 items-center gap-3`,children:[(0,W.jsx)(me,{checked:Q(e.value),label:e.label,onChange:t=>c(e.id,{value:B(t?`project.yes`:`project.no`)})}),(0,W.jsx)(`span`,{className:`text-[14px] text-ink-2`,children:Q(e.value)?B(`project.yes`):B(`project.no`)})]}):(0,W.jsx)(F,{ref:u(`${e.id}:value`),rows:1,minRows:r===`longtext`?2:1,maxRows:10,value:e.value,placeholder:B(`project.factValue`),onChange:t=>c(e.id,{value:t.target.value}),className:`min-h-11`}),(0,W.jsx)(ht,{type:e.type,detected:t,onChange:t=>c(e.id,{type:t})}),n?null:(0,W.jsx)(I,{label:B(`project.remove`),onClick:()=>o(t=>t.filter(t=>t.id!==e.id)),className:`size-11 rounded-lg hover:text-rose`,children:(0,W.jsx)(A,{className:`size-4`})})]},e.id)})}),a.length<G.facts&&!n?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 ${a.length?`mt-4`:``}`,children:[(0,W.jsxs)(z,{variant:`secondary`,size:`sm`,onClick:()=>l({},`label`),children:[(0,W.jsx)(b,{className:`size-4`}),` `,B(`project.factAdd`)]}),d.map(e=>(0,W.jsxs)(`button`,{type:`button`,onClick:()=>l({key:e.key,label:de===`en`?e.en:e.de},`value`),className:`inline-flex h-8 items-center gap-1 rounded-full bg-paper-2 px-3 text-[13px] text-ink-2 transition hover:bg-paper-3 hover:text-ink`,children:[(0,W.jsx)(b,{className:`size-3.5`}),` `,de===`en`?e.en:e.de]},e.key))]}):null]})}function _t({project:e,save:t}){let[n,r]=(0,U.useState)(e.brand.name??``),[i,a]=(0,U.useState)(e.brand.about??``),o=k({name:n.trim(),about:i.trim()},e=>t({brand:e}));return(0,W.jsx)(O,{title:B(`project.base`),hint:B(`project.baseHint`),save:o,locked:e.readOnly,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(j,{children:B(`project.title`)}),(0,W.jsx)(R,{value:n,maxLength:120,onChange:e=>r(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:B(`project.titleHint`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(j,{children:B(`project.about`)}),(0,W.jsx)(F,{minRows:4,value:i,onChange:e=>a(e.target.value)}),(0,W.jsx)(`p`,{className:`mt-1.5 text-[13px] text-ink-3`,children:B(`project.aboutHint`)})]})]})})}function vt({project:e,save:t}){let[n,r]=(0,U.useState)(!1),[i,a]=(0,U.useState)(e.name),o=V({mutationFn:()=>t({name:i.trim()}),onSuccess:()=>r(!1)});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(I,{label:B(`project.rename`),onClick:()=>{a(e.name),r(!0)},children:(0,W.jsx)(_,{className:`size-4`})}),(0,W.jsx)(P,{open:n,onClose:()=>r(!1),title:B(`project.rename`),children:(0,W.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),i.trim()&&o.mutate()},children:[(0,W.jsx)(R,{autoFocus:!0,value:i,maxLength:80,onChange:e=>a(e.target.value)}),o.error?(0,W.jsx)(`p`,{className:`mt-3 text-[14px] text-rose`,children:o.error.message}):null,(0,W.jsxs)(`div`,{className:`mt-5 flex justify-end gap-2`,children:[(0,W.jsx)(z,{variant:`ghost`,onClick:()=>r(!1),children:B(`common.cancel`)}),(0,W.jsx)(z,{type:`submit`,busy:o.isPending,disabled:!i.trim(),children:B(`settings.save`)})]})]})})]})}function $({id:e,children:t}){return(0,W.jsx)(`div`,{id:e,className:`scroll-mt-24 max-md:scroll-mt-36`,children:t})}function yt({project:e}){let t=l(),n=oe(e.id),[r,i]=(0,U.useState)(0),a=async n=>{await c.patch(`/api/studio/projects/${e.id}`,n),await t.invalidateQueries({queryKey:[`projects`]})},o=V({mutationFn:()=>c.del(`/api/studio/projects/${e.id}`),onSuccess:()=>t.invalidateQueries({queryKey:[`projects`]})}),s=_e(),u=n.data??{files:[],embeddings:!0},f=`${e.id}:${r}`,p=e.readOnly;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-9 pb-20`,children:[s?(0,W.jsxs)(`div`,{className:`-mb-3 flex items-center gap-1`,children:[(0,W.jsx)(d,{}),p?null:(0,W.jsx)(vt,{project:e,save:a})]}):null,p?(0,W.jsx)(ye,{children:ve(e)}):(0,W.jsx)(Re,{projectId:e.id,onChanged:()=>i(e=>e+1)},e.id),(0,W.jsx)($,{id:`base`,children:(0,W.jsx)(_t,{project:e,save:a},`base:${f}`)}),(0,W.jsx)($,{id:`logos`,children:(0,W.jsx)($e,{projectId:e.id,data:u,readOnly:p})}),(0,W.jsx)($,{id:`colors`,children:(0,W.jsx)(Xe,{colors:e.brand.colors??[],save:e=>a({brand:{colors:e}}),readOnly:p},`colors:${f}`)}),(0,W.jsx)($,{id:`assets`,children:(0,W.jsx)(rt,{projectId:e.id,data:u,readOnly:p})}),(0,W.jsx)($,{id:`documents`,children:(0,W.jsx)(pt,{projectId:e.id,data:u,readOnly:p})}),(0,W.jsx)($,{id:`facts`,children:(0,W.jsx)(gt,{facts:e.facts,save:e=>a({facts:e}),readOnly:p},`facts:${f}`)}),s&&!p?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(z,{variant:`danger`,busy:o.isPending,onClick:()=>confirm(`${B(`settings.delete`)}?`)&&o.mutate(),children:B(`settings.delete`)}),o.error?(0,W.jsx)(`p`,{className:`mt-2 text-[14px] text-rose`,children:o.error.message}):null]}):null]})}function bt(){return[{id:`base`,label:B(`project.base`)},{id:`logos`,label:B(`project.logos`)},{id:`colors`,label:B(`project.colors`)},{id:`assets`,label:B(`project.assets`)},{id:`documents`,label:B(`project.documents`)},{id:`facts`,label:B(`project.facts`)}]}function xt(e){let t=e.join(` `),[n,r]=(0,U.useState)(e[0]);return(0,U.useEffect)(()=>{let e=t.split(` `),n=0,i=()=>{n=0;let t=window.scrollY>0&&window.innerHeight+window.scrollY>=document.documentElement.scrollHeight-4,i=Math.max(160,window.innerHeight/3),a=e[0];for(let t of e){let e=document.getElementById(t)?.getBoundingClientRect().top;e!==void 0&&e<=i&&(a=t)}r(t?e.at(-1):a)},a=()=>{n||=requestAnimationFrame(i)};return i(),window.addEventListener(`scroll`,a,{passive:!0}),window.addEventListener(`resize`,a),()=>{cancelAnimationFrame(n),window.removeEventListener(`scroll`,a),window.removeEventListener(`resize`,a)}},[t]),n}function St(e,t){let n=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;document.getElementById(e)?.scrollIntoView({block:`start`,behavior:t&&!n?`smooth`:`auto`})}function Ct(){let{project:e,loading:t}=ge(),n=i(),{hash:a}=r(),o=bt(),s=xt(o.map(e=>e.id)),c=e=>{St(e,!0),n({hash:e},{replace:!0})},l=e?.id;return(0,U.useEffect)(()=>{l&&a&&requestAnimationFrame(()=>St(a.slice(1),!1))},[l]),(0,W.jsxs)(`div`,{className:`animate-rise`,children:[(0,W.jsx)(`h1`,{className:`font-display font-semibold text-[28px] tracking-tight`,children:B(`nav.project`)}),(0,W.jsxs)(`div`,{className:`mt-6 grid gap-6 md:mt-8 md:grid-cols-[200px_minmax(0,1fr)] md:gap-10`,children:[(0,W.jsx)(`nav`,{className:`max-md:hidden`,children:(0,W.jsx)(`ul`,{className:`sticky top-24 flex flex-col gap-0.5`,children:o.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`a`,{href:`#${e.id}`,onClick:t=>{t.preventDefault(),c(e.id)},"aria-current":e.id===s?`location`:void 0,className:N(`block rounded-lg px-3 py-2 text-[14px] transition`,e.id===s?`bg-paper-2 font-medium text-ink`:`text-ink-3 hover:bg-accent hover:text-ink`),children:e.label})},e.id))})}),(0,W.jsx)(`div`,{className:`-mx-4 sticky top-16 z-30 bg-background/85 px-4 py-2 backdrop-blur-md md:hidden`,children:(0,W.jsx)(he,{value:s??``,onChange:c,options:o.map(e=>({value:e.id,label:e.label}))})}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[e?(0,W.jsx)(yt,{project:e},e.id):null,e||t?null:(0,W.jsx)(fe,{children:B(`settings.noProject`)})]})]})]})}export{Ct as ProjectPage};