ocean-brain 0.8.1 → 0.8.2

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 (78) hide show
  1. package/README.md +113 -0
  2. package/dist/mcp.js +230 -291
  3. package/package.json +5 -5
  4. package/server/client/dist/assets/ArrowRight.es-g2YZTklZ.js +1 -0
  5. package/server/client/dist/assets/Calendar-BP6HTuSn.js +25 -0
  6. package/server/client/dist/assets/Callout-B_IPSF_5.js +1 -0
  7. package/server/client/dist/assets/Copy.es-CNxe4ujr.js +1 -0
  8. package/server/client/dist/assets/Graph-D9GeO71k.js +1 -0
  9. package/server/client/dist/assets/Graph-Xha3fwhp.js +46 -0
  10. package/server/client/dist/assets/Image-BLEjLUqd.js +1 -0
  11. package/server/client/dist/assets/Image.es-DnON8cv2.js +1 -0
  12. package/server/client/dist/assets/Note-DjrCYtat.js +24 -0
  13. package/server/client/dist/assets/NotePropertiesPanel-2DgXEM4B.js +2 -0
  14. package/server/client/dist/assets/Plus.es-CQ8wn2is.js +1 -0
  15. package/server/client/dist/assets/Reminders-B4l3KdlK.js +1 -0
  16. package/server/client/dist/assets/Search-BN5sf7bE.js +1 -0
  17. package/server/client/dist/assets/SurfaceCard-BZm73nyS.js +1 -0
  18. package/server/client/dist/assets/Tag-oSnmViVp.js +1 -0
  19. package/server/client/dist/assets/TagNotes-BDTCcJcL.js +1 -0
  20. package/server/client/dist/assets/Trash.es-0aPpA-3S.js +1 -0
  21. package/server/client/dist/assets/ViewNotes-CiZtGJNE.js +1 -0
  22. package/server/client/dist/assets/{ViewSectionDialog-brTrsF6G.js → ViewSectionDialog-Ctl_694Y.js} +17 -17
  23. package/server/client/dist/assets/Views-D-zlatYD.js +1 -0
  24. package/server/client/dist/assets/app-DmqIOMWF.css +1 -0
  25. package/server/client/dist/assets/app-cTRcKMGc.js +26 -0
  26. package/server/client/dist/assets/floating-ui.react-dom-wWLZ1CdM.js +1 -0
  27. package/server/client/dist/assets/{image.api-CYsjXiMr.js → image.api-CVuuvTBk.js} +1 -1
  28. package/server/client/dist/assets/index-DKJChPr4.js +1 -0
  29. package/server/client/dist/assets/manage-image-BZjaxp-f.js +1 -0
  30. package/server/client/dist/assets/manage-image-detail-DPv0FQ2m.js +1 -0
  31. package/server/client/dist/assets/{mcp-Dd98N9Hq.js → mcp-CT_9IV2c.js} +2 -2
  32. package/server/client/dist/assets/mcp-admin-adapter-xAuyZc_M.js +1 -0
  33. package/server/client/dist/assets/note-core-Buwzyxi7.js +13 -0
  34. package/server/client/dist/assets/note-runtime-CPDVOFEo.js +168 -0
  35. package/server/client/dist/assets/note-ui-CHI-tzj-.js +2 -0
  36. package/server/client/dist/assets/{index-DPI6YoDt.css → note-ui-DL8owV-U.css} +1 -1
  37. package/server/client/dist/assets/note.api-D_00ZzJC.js +356 -0
  38. package/server/client/dist/assets/placeholder-DbdGiYGL.js +34 -0
  39. package/server/client/dist/assets/preload-helper-BXl3LOEh.js +1 -0
  40. package/server/client/dist/assets/properties-D447wsWk.js +1 -0
  41. package/server/client/dist/assets/route-preload.js +2 -0
  42. package/server/client/dist/assets/{tag.api-CwmC8crB.js → tag.api-CX0SE06J.js} +1 -1
  43. package/server/client/dist/assets/time-B3pt8vt4.js +9 -0
  44. package/server/client/dist/assets/trash-8sH7EZgc.js +1 -0
  45. package/server/client/dist/assets/url-BSnWpmJx.js +1 -0
  46. package/server/client/dist/assets/{useReminderMutate-DuVKxpBh.js → useReminderMutate-CLK1tHvT.js} +4 -4
  47. package/server/client/dist/index.html +10 -5
  48. package/server/dist/app.js +1 -1
  49. package/server/dist/modules/blocknote.js +262 -75
  50. package/server/dist/modules/error-handler.js +8 -0
  51. package/server/client/dist/assets/ArrowRight.es-CbA8ey6a.js +0 -1
  52. package/server/client/dist/assets/Calendar-CgWgr1BV.js +0 -25
  53. package/server/client/dist/assets/Callout-DKruIT0f.js +0 -1
  54. package/server/client/dist/assets/Copy.es-DFbgpaNJ.js +0 -1
  55. package/server/client/dist/assets/Graph-kCltGRlY.js +0 -1
  56. package/server/client/dist/assets/Image-7W0DZwMo.js +0 -1
  57. package/server/client/dist/assets/Image.es-5pXLx9TU.js +0 -1
  58. package/server/client/dist/assets/Note-BW6Np_5g.js +0 -20
  59. package/server/client/dist/assets/Plus.es-B0sg64VJ.js +0 -1
  60. package/server/client/dist/assets/Reminders-C10fHQcl.js +0 -1
  61. package/server/client/dist/assets/Search-tf2nV4v0.js +0 -1
  62. package/server/client/dist/assets/SurfaceCard-pydtvHfu.js +0 -1
  63. package/server/client/dist/assets/Tag-uCoYbISy.js +0 -1
  64. package/server/client/dist/assets/TagNotes-CqOcQiRw.js +0 -1
  65. package/server/client/dist/assets/Trash.es-w32Goxfa.js +0 -1
  66. package/server/client/dist/assets/ViewNotes-slPXXoOY.js +0 -1
  67. package/server/client/dist/assets/Views-B_wsb-XJ.js +0 -1
  68. package/server/client/dist/assets/graph-vendor-BAF95C0g.js +0 -46
  69. package/server/client/dist/assets/index-BR05aSXr.js +0 -342
  70. package/server/client/dist/assets/index-D83QbOcw.js +0 -1
  71. package/server/client/dist/assets/manage-image-BYIhWu56.js +0 -1
  72. package/server/client/dist/assets/manage-image-detail-6KgmQvbN.js +0 -1
  73. package/server/client/dist/assets/mcp-admin-adapter-DOgBsYpl.js +0 -1
  74. package/server/client/dist/assets/note-core-CMGUaW1v.js +0 -176
  75. package/server/client/dist/assets/note-vendor-Hoz9Q4-4.js +0 -54
  76. package/server/client/dist/assets/placeholder-siHGg9aK.js +0 -34
  77. package/server/client/dist/assets/properties-CyVRKgcT.js +0 -1
  78. package/server/client/dist/assets/trash-wojQBK9Z.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as g,j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";function u({src:r,alt:n,loading:t="lazy",className:i}){const s=g.useRef(null);return g.useEffect(()=>{if(!s.current||t!=="lazy"||!r)return;const A=new IntersectionObserver(([c])=>{if(c.isIntersecting){const a=c.target;a.src=a.dataset.src,A.unobserve(a)}});return A.observe(s.current),()=>{A.disconnect()}},[t,r]),e.jsx(e.Fragment,{children:t!=="lazy"?e.jsx("img",{src:r,alt:n,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()}):e.jsx("img",{ref:s,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQIW2O4evXqfwAIgQN/QHwrfwAAAABJRU5ErkJggg==",alt:n,"data-src":r,className:`${i??""} dark:brightness-[0.85] dark:saturate-[0.9]`.trim()})})}export{u as I};
@@ -0,0 +1 @@
1
+ import{r as a}from"./floating-ui.react-dom-wWLZ1CdM.js";import{R as m}from"./note.api-D_00ZzJC.js";const n=new Map([["bold",a.createElement(a.Fragment,null,a.createElement("path",{d:"M144,96a16,16,0,1,1,16,16A16,16,0,0,1,144,96Zm92-40V200a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56ZM44,60v79.72l33.86-33.86a20,20,0,0,1,28.28,0L147.31,147l17.18-17.17a20,20,0,0,1,28.28,0L212,149.09V60Zm0,136H162.34L92,125.66l-48,48Zm168,0V183l-33.37-33.37L164.28,164l32,32Z"}))],["duotone",a.createElement(a.Fragment,null,a.createElement("path",{d:"M224,56V178.06l-39.72-39.72a8,8,0,0,0-11.31,0L147.31,164,97.66,114.34a8,8,0,0,0-11.32,0L32,168.69V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z",opacity:"0.2"}),a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["fill",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM156,88a12,12,0,1,1-12,12A12,12,0,0,1,156,88Zm60,112H40V160.69l46.34-46.35a8,8,0,0,1,11.32,0h0L165,181.66a8,8,0,0,0,11.32-11.32l-17.66-17.65L173,138.34a8,8,0,0,1,11.31,0L216,170.07V200Z"}))],["light",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,42H40A14,14,0,0,0,26,56V200a14,14,0,0,0,14,14H216a14,14,0,0,0,14-14V56A14,14,0,0,0,216,42ZM40,54H216a2,2,0,0,1,2,2V163.57L188.53,134.1a14,14,0,0,0-19.8,0l-21.42,21.42L101.9,110.1a14,14,0,0,0-19.8,0L38,154.2V56A2,2,0,0,1,40,54ZM38,200V171.17l52.58-52.58a2,2,0,0,1,2.84,0L176.83,202H40A2,2,0,0,1,38,200Zm178,2H193.8l-38-38,21.41-21.42a2,2,0,0,1,2.83,0l38,38V200A2,2,0,0,1,216,202ZM146,100a10,10,0,1,1,10,10A10,10,0,0,1,146,100Z"}))],["regular",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm0,16V158.75l-26.07-26.06a16,16,0,0,0-22.63,0l-20,20-44-44a16,16,0,0,0-22.62,0L40,149.37V56ZM40,172l52-52,80,80H40Zm176,28H194.63l-36-36,20-20L216,181.38V200ZM144,100a12,12,0,1,1,12,12A12,12,0,0,1,144,100Z"}))],["thin",a.createElement(a.Fragment,null,a.createElement("path",{d:"M216,44H40A12,12,0,0,0,28,56V200a12,12,0,0,0,12,12H216a12,12,0,0,0,12-12V56A12,12,0,0,0,216,44ZM40,52H216a4,4,0,0,1,4,4V168.4l-32.89-32.89a12,12,0,0,0-17,0l-22.83,22.83-46.82-46.83a12,12,0,0,0-17,0L36,159V56A4,4,0,0,1,40,52ZM36,200V170.34l53.17-53.17a4,4,0,0,1,5.66,0L181.66,204H40A4,4,0,0,1,36,200Zm180,4H193l-40-40,22.83-22.83a4,4,0,0,1,5.66,0L220,179.71V200A4,4,0,0,1,216,204ZM148,100a8,8,0,1,1,8,8A8,8,0,0,1,148,100Z"}))]]),e=a.forwardRef((l,t)=>a.createElement(m,{ref:t,...l,weights:n}));e.displayName="ImageIcon";const Z=e;export{Z as I};
@@ -0,0 +1,24 @@
1
+ import{r as o,j as a}from"./floating-ui.react-dom-wWLZ1CdM.js";import{H as fn,R as pn,Z as N,a9 as ft,aA as hn,T as E,at as M,au as T,a5 as J,ah as pt,a4 as ht,aB as mn,a8 as Re,U as Ke,aC as mt,aD as gn,aE as xn,aF as vn,a3 as Le,aw as yn,aG as bn,aH as wn,aI as Fe,af as Cn,aJ as Nn,ag as Sn,I as gt,aq as jn,aK as ze,aL as Rn,aM as An,aN as kn,aO as En,aa as Ye,aj as qe,ab as Qe,ai as Tn,ac as ie,ad as Dn}from"./note.api-D_00ZzJC.js";import{j as xe,k as Mn,r as Pn,M as xt,m as _n,d as $e,e as On,i as Q,g as Bn,b as vt,l as yt,s as Ln,o as et,f as Fn}from"./time-B3pt8vt4.js";import{m as $n,c as Un,C as tt}from"./Callout-B_IPSF_5.js";import{J as bt,A as wt,a as Hn,N as In,p as Vn}from"./NotePropertiesPanel-2DgXEM4B.js";import{N as Ae,b as zn,e as Wn}from"./url-BSnWpmJx.js";import{S as Kn}from"./SurfaceCard-BZm73nyS.js";import{u as Yn,R as qn}from"./useReminderMutate-CLK1tHvT.js";import{n as Qn}from"./Plus.es-CQ8wn2is.js";import{h as Ge,m as Gn,L as Ct,Z as Nt,M as Zn,K as Jn,a as Xn}from"./note-ui-CHI-tzj-.js";import{u as er}from"./image.api-CVuuvTBk.js";import{L as tr,q as nr,B as me,G as rr,t as nt}from"./note-core-Buwzyxi7.js";import{s as ar}from"./Copy.es-CNxe4ujr.js";import{f as sr,c as or}from"./tag.api-CX0SE06J.js";import{cn as rt}from"./note-runtime-CPDVOFEo.js";import"./preload-helper-BXl3LOEh.js";function ir(e,n){if(e===void 0)return{shouldBlockFn:()=>!0,withResolver:!1};if("shouldBlockFn"in e)return e;if(typeof e=="function")return{shouldBlockFn:async()=>await e(),enableBeforeUnload:!0,withResolver:!1};const t=!!(e.condition??!0),s=e.blockerFn;return{shouldBlockFn:async()=>t&&s!==void 0?await s():t,enableBeforeUnload:t,withResolver:s===void 0}}function cr(e,n){const{shouldBlockFn:t,enableBeforeUnload:s=!0,disabled:r=!1,withResolver:i=!1}=ir(e),c=fn(),{history:l}=c,[p,u]=o.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return o.useEffect(()=>{const h=async x=>{function m(A){const w=c.parseLocation(A),f=c.getMatchedRoutes(w.pathname);return f.foundRoute===void 0?{routeId:"__notFound__",fullPath:w.pathname,pathname:w.pathname,params:f.routeParams,search:c.options.parseSearch(A.search)}:{routeId:f.foundRoute.id,fullPath:f.foundRoute.fullPath,pathname:w.pathname,params:f.routeParams,search:c.options.parseSearch(A.search)}}const d=m(x.currentLocation),v=m(x.nextLocation);if(d.routeId==="__notFound__"&&v.routeId!=="__notFound__")return!1;const b=await t({action:x.action,current:d,next:v});if(!i)return b;if(!b)return!1;const j=await new Promise(A=>{u({status:"blocked",current:d,next:v,action:x.action,proceed:()=>A(!1),reset:()=>A(!0)})});return u({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),j};return r?void 0:l.block({blockerFn:h,enableBeforeUnload:s})},[t,s,r,i,l,c]),p}const lr=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M208,88H152V32Z",opacity:"0.2"}),o.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM152,88V44l44,44Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Z"}))]]),St=o.forwardRef((e,n)=>o.createElement(pn,{ref:n,...e,weights:lr}));St.displayName="FileIcon";const dr=St;function ur({title:e,description:n,selected:t=!1,onClick:s,children:r}){return a.jsxs("button",{type:"button","aria-pressed":t,className:`focus-ring-soft flex w-full items-start justify-between gap-3 p-3 text-left transition-colors sm:p-4 ${t?"surface-floating bg-elevated":"rounded-[14px] border border-border-subtle bg-transparent hover:border-border-secondary hover:bg-hover-subtle"}`,onClick:s,children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(N,{as:"div",variant:"body",weight:"semibold",tone:t?"default":"secondary",children:e}),a.jsx(N,{as:"div",variant:"meta",weight:"medium",tone:t?"secondary":"tertiary",className:"mt-1",children:n})]}),r?a.jsx("div",{className:"shrink-0",children:r}):null]})}const fr=e=>{const{data:n}=ft({queryKey:E.notes.backReferences(e.noteId),async queryFn(){const t=await hn(e.noteId);if(t.type==="error")throw t;return t.backReferences}});return e.render(n)},pr=[{value:"narrow",label:"Narrow",description:"Optimized for reading long-form content"},{value:"wide",label:"Wide",description:"Balanced width suitable for most content"},{value:"full",label:"Full Width",description:"Maximize screen space utilization"}];function hr({isOpen:e,onClose:n,onSave:t,currentLayout:s="wide"}){const[r,i]=o.useState(s);o.useEffect(()=>{e&&i(s)},[e,s]);const c=()=>{t(r),n()};return a.jsxs(M,{isOpen:e,onClose:n,variant:"compact",children:[a.jsx(M.Header,{title:"Layout Settings",onClose:n}),a.jsx(M.Body,{children:a.jsx("div",{className:"flex flex-col gap-3 sm:gap-4",children:a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(N,{as:"div",variant:"body",weight:"semibold",tone:"secondary",children:"Note layout"}),a.jsx("div",{className:"flex flex-col gap-2",children:pr.map(l=>a.jsx(ur,{title:l.label,description:l.description,selected:r===l.value,onClick:()=>i(l.value)},l.value))})]})})}),a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(T,{variant:"primary",size:"sm",onClick:c,children:"Apply"})]})})]})}const ge=e=>{const n=/^\d+$/.test(e)?Number(e):Date.parse(e);return Number.isFinite(n)?n:null},Se=(e,n)=>{const t=ge(e),s=ge(n);return t===null||s===null?e===n?0:null:t===s?0:t<s?-1:1},mr=2200;function gr({status:e,savedAt:n,savedVersion:t,confirmationRevision:s}){const[r,i]=o.useState(()=>Date.now()),[c,l]=o.useState(!1);o.useEffect(()=>{if(e!=="saved")return;const d=window.setTimeout(()=>i(Date.now()),Mn(ge(t),r));return()=>window.clearTimeout(d)},[r,t,e]),o.useEffect(()=>{if(s===0)return;l(!0);const d=window.setTimeout(()=>l(!1),mr);return()=>window.clearTimeout(d)},[s]);const p=e==="saved"&&c,u=e==="pending"?"Saving...":e==="saving"?"Saving now...":e==="error"?"Save failed. Try again.":e==="conflict"?"Save paused: changed elsewhere":`Saved ${Pn(ge(t),r)}`,h=J("inline-flex items-center gap-2 transition-colors",e==="saved"&&!p&&"text-fg-secondary",p&&"text-accent-success",(e==="pending"||e==="saving")&&"text-fg-default",(e==="error"||e==="conflict")&&"text-fg-error"),x=J("save-progress-ring flex h-4 w-4 shrink-0 items-center justify-center rounded-full",(e==="pending"||e==="saving")&&"save-progress-ring-active",e==="saved"&&p&&"save-progress-ring-complete",(e==="error"||e==="conflict")&&"save-progress-ring-error"),m=e==="error"||e==="conflict"?a.jsx($n,{className:"h-3.5 w-3.5",weight:"fill"}):a.jsx("span",{className:x,"aria-hidden":!0,children:a.jsx("span",{className:"h-2 w-2 rounded-full bg-elevated"})});return a.jsxs(N,{as:"span",variant:"label",weight:"medium",className:h,role:"status","aria-live":"polite",title:n,children:[m,u]})}function xr({title:e,titleRef:n,isPinned:t,createdAt:s,saveStatus:r,savedAt:i,savedVersion:c,saveConfirmationRevision:l,onTitleChange:p,onCopyMarkdown:u,onDownloadDocument:h,onTogglePinned:x,onChangeLayout:m,onCloneNote:d,onRestoreVersion:v,onDelete:b,onSave:S}){return a.jsx("div",{className:"surface-floating sticky top-20 z-[1001] mb-7 px-5 pt-4 pb-3.5",children:a.jsxs("div",{className:"flex flex-col gap-3.5",children:[a.jsxs("div",{className:"flex items-start justify-between gap-5",children:[a.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[a.jsx(N,{as:"div",variant:"micro",weight:"semibold",tracking:"widest",transform:"uppercase",tone:"tertiary",className:"mb-1.5",children:"Thought in progress"}),a.jsx("input",{ref:n,"aria-label":"Note title",placeholder:"Title",className:"text-heading sm:text-display w-full bg-transparent font-semibold leading-[1.25] tracking-[-0.02em] outline-none",type:"text",value:e,onChange:j=>p(j.target.value)})]}),a.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[a.jsx(pt,{button:a.jsx(xt,{label:"Note actions",size:"lg"}),items:[{name:"Copy Markdown",onClick:u},{name:"Download document",onClick:h},{type:"separator",key:"export-separator"},{name:t?"Unpin":"Pin",onClick:x},{name:"Change layout",onClick:m},{type:"separator"},{name:"Clone this note",onClick:d},{name:"Restore previous version",onClick:v},{type:"separator"},{name:"Delete",onClick:b}]}),a.jsx(T,{size:"sm",variant:"subtle",isLoading:r==="saving",disabled:r==="conflict",onClick:S,children:"Save"})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-x-2.5 gap-y-1.5 border-t border-border-subtle/80 pt-3",children:[t&&a.jsxs(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"inline-flex items-center gap-1.5",children:[a.jsx(_n,{className:"h-3 w-3",weight:"fill"}),"Pinned"]}),t&&a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsx(gr,{status:r,savedAt:i,savedVersion:c,confirmationRevision:l}),a.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),a.jsxs(N,{as:"span",variant:"micro",weight:"medium",tone:"tertiary",children:["Created ",s]})]})]})})}const vr=/[:{}[\],&*#?|<>=!%@`-]/,yr="/assets/images/",br=e=>e.trim().toLowerCase().replace(/\s+/g,"-").replace(/[\\/:*?"<>|]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"untitled-note",Ne=e=>e?vr.test(e)||/^\s|\s$/.test(e)?JSON.stringify(e):e:'""',je=e=>{if(!e)return;const n=Number(e);return Number.isFinite(n)?new Date(n).toISOString():e},Ze=()=>typeof window>"u"||!window.location?.origin?"http://localhost":window.location.origin,ke=(e,n=Ze())=>{try{const t=new URL(e,n);return t.origin===n&&t.pathname.startsWith(yr)}catch{return!1}},jt=(e,n=Ze())=>{const t=new URL(e,n);return`${t.pathname}${t.search}`},Rt=e=>e.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase()??"",wr=e=>e.trim().replace(/[\\/:*?"<>|]/g,"-").split("").map(s=>s.charCodeAt(0)<32?"-":s).join("").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")||"image",Cr=e=>{const n=e.lastIndexOf(".");return n<=0||n===e.length-1?{baseName:e,extension:""}:{baseName:e.slice(0,n),extension:e.slice(n)}},At=(e,n,t)=>{const r=new URL(e,Ze()).pathname.split("/").filter(Boolean),i=decodeURIComponent(r[r.length-1]??""),c=`image-${n+1}`,{baseName:l,extension:p}=Cr(wr(i||c));let u=`${l}${p}`,h=2;for(;t.has(u);)u=`${l}-${h}${p}`,h+=1;return t.add(u),`assets/${u}`},Nr=(e,n)=>{let t=null;for(let s=n;s<e.length;s+=1){const r=e[s];if(t){r===t&&(t=null);continue}if(r==='"'||r==="'"){t=r;continue}if(r===">")return s}return-1},Sr=(e,n)=>{let t=n;for(;t<e.length;){const s=e.toLowerCase().indexOf("<img",t);if(s===-1)return-1;const r=e[s+4],i=s===0?-1:e.lastIndexOf("<",s-1),c=s===0?-1:e.lastIndexOf(">",s-1);if(i<=c&&(!r||/[\s/>]/.test(r)))return s;t=s+4}return-1},jr=(e,n,t,s)=>{let r=n;for(;r<t;){for(;r<t&&/[\s/]/.test(e[r]);)r+=1;const i=r;for(;r<t&&/[^\s=/>]/.test(e[r]);)r+=1;const c=e.slice(i,r).toLowerCase();for(;r<t&&/\s/.test(e[r]);)r+=1;if(e[r]!=="=")continue;for(r+=1;r<t&&/\s/.test(e[r]);)r+=1;const l=e[r];if(l==='"'||l==="'"){const u=r+1,h=e.indexOf(l,u);if(h===-1||h>t)return;if(r=h+1,c===s)return{end:h,start:u,value:e.slice(u,h)};continue}const p=r;for(;r<t&&/[^\s>]/.test(e[r]);)r+=1;if(c===s)return{end:r,start:p,value:e.slice(p,r)}}},kt=e=>{const n=[];let t=0;for(;t<e.length;){const s=Sr(e,t);if(s===-1)break;const r=Nr(e,s+4);if(r===-1)break;const i=jr(e,s+4,r,"src");i&&n.push({end:r+1,source:i,start:s}),t=r+1}return n},Et=(e,n)=>{let t=e;for(const s of[...n].sort((r,i)=>i.start-r.start))t=`${t.slice(0,s.start)}${s.value}${t.slice(s.end)}`;return t},Tt=(e,n)=>{let t=e;for(const s of[...n].sort((r,i)=>i.start-r.start))t=`${t.slice(0,s.start)}${s.value}${t.slice(s.end)}`;return t},Dt=e=>{const n=[];let t=0;for(;t<e.length;){const s=e.indexOf("![",t);if(s===-1)break;let r=s+2,i=1;for(;r<e.length&&i>0&&e[r]!==`
2
+ `;){if(e[r]==="\\"){r+=2;continue}e[r]==="["?i+=1:e[r]==="]"&&(i-=1),r+=1}if(i!==0||e[r]!=="("){t=s+2;continue}const c=r+1;let l=c;for(;l<e.length&&e[l]!==`
3
+ `&&/\s/.test(e[l]);)l+=1;if(l>=e.length||e[l]===`
4
+ `){t=s+2;continue}let p=l,u=l,h=l;if(e[l]==="<"){for(r=l+1;r<e.length&&e[r]!==">"&&e[r]!==`
5
+ `;)r+=e[r]==="\\"?2:1;if(e[r]!==">"){t=s+2;continue}p=r+1,u=l+1,h=r}else{let x=0;for(r=l;r<e.length&&e[r]!==`
6
+ `;){const m=e[r];if(m==="\\"){r+=2;continue}if(/\s/.test(m)&&x===0)break;if(m==="(")x+=1;else if(m===")"){if(x===0)break;x-=1}r+=1}p=r,u=l,h=p}if(h<=u){t=s+2;continue}for(r=p;r<e.length&&e[r]!==`
7
+ `&&/\s/.test(e[r]);)r+=1;if(e[r]==='"'||e[r]==="'"){const x=e[r];for(r+=1;r<e.length&&e[r]!==`
8
+ `;){if(e[r]==="\\"){r+=2;continue}if(e[r]===x){r+=1;break}r+=1}}for(;r<e.length&&e[r]!==`
9
+ `&&/\s/.test(e[r]);)r+=1;if(e[r]!==")"){t=s+2;continue}n.push({end:r+1,source:{end:p,start:c,value:e.slice(u,h)},start:s}),t=r+1}return n},Rr=(e,n)=>`${br(e)}.${n}`,Ar=({id:e,title:n,createdAt:t,updatedAt:s})=>{const r=["---",`title: ${Ne(n)}`,`note_id: ${Ne(e)}`],i=je(t),c=je(s);return i&&r.push(`created_at: ${Ne(i)}`),c&&r.push(`updated_at: ${Ne(c)}`),r.push("source: ocean-brain","---"),r.join(`
10
+ `)},Mt=(e,n,t=!1)=>t?`${Ar(n)}
11
+
12
+ ${e}`:e,Pt=(e,n,{includeMetadata:t=!1}={})=>{const s=Mt(e,n,t),r=Dt(s).filter(i=>ke(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return Tt(s,r)},_t=(e,n,{includeMetadata:t=!1}={})=>`${t?`<!--
13
+ source: ocean-brain
14
+ note_id: ${n.id}
15
+ title: ${n.title}
16
+ created_at: ${je(n.createdAt)??""}
17
+ updated_at: ${je(n.updatedAt)??""}
18
+ -->
19
+ `:""}${e}`,kr=(e,n,{includeMetadata:t=!1}={})=>{const s=_t(e,n,{includeMetadata:t}),r=kt(s).filter(i=>ke(i.source.value)).map(i=>({end:i.end,start:i.start,value:""}));return Et(s,r)},Er=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new bt,i=_t(e,n,{includeMetadata:s}),c=kt(i),l=[],p=new Set,u=new Map;for(const{source:h}of c){if(!ke(h.value))continue;const x=jt(h.value);let m=u.get(x);if(!m){m=At(x,u.size,p),u.set(x,m);const d=await t(x,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${x}`);if(!Rt(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${x}`);r.file(m,new Uint8Array(await d.arrayBuffer()))}l.push({end:h.end,start:h.start,value:`./${m}`})}return r.file("note.html",Et(i,l)),r.generateAsync({type:"blob"})},Tr=async(e,n,{fetchImpl:t=fetch,includeMetadata:s=!1}={})=>{const r=new bt,i=Mt(e,n,s),c=Dt(i),l=[],p=new Set,u=new Map;for(const{source:h}of c){if(!ke(h.value))continue;const x=jt(h.value);let m=u.get(x);if(!m){m=At(x,u.size,p),u.set(x,m);const d=await t(x,{credentials:"same-origin"});if(!d.ok)throw new Error(`Failed to fetch image asset: ${x}`);if(!Rt(d).startsWith("image/"))throw new Error(`Image asset did not return image content: ${x}`);r.file(m,new Uint8Array(await d.arrayBuffer()))}l.push({end:h.end,start:h.start,value:`./${m}`})}return r.file("note.md",Tt(i,l)),r.generateAsync({type:"blob"})},Dr=(e,n)=>{const t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download=n,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(t)},Ot={html:{extension:"html",getContent:e=>e.getHtml(),createDocumentBlob:(e,n)=>new Blob([kr(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/html;charset=utf-8"}),createZipBlob:(e,n)=>Er(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})},markdown:{extension:"md",getContent:e=>e.getMarkdown(),createDocumentBlob:(e,n)=>new Blob([Pt(e,n.metadata,{includeMetadata:n.includeMetadata})],{type:"text/markdown;charset=utf-8"}),createZipBlob:(e,n)=>Tr(e,n.metadata,{fetchImpl:n.fetchImpl,includeMetadata:n.includeMetadata})}},Bt=(e,n)=>n?"zip":Ot[e].extension,Mr=async e=>{const n=Ot[e.format],t=n.getContent(e.source);if(t===void 0)return{type:"not-ready",format:e.format};const s=Bt(e.format,e.includeAssets);return{type:"success",blob:e.includeAssets?await n.createZipBlob(t,e):n.createDocumentBlob(t,e),filename:Rr(e.metadata.title,s)}},Pr=e=>e==="markdown"?"Markdown is not ready yet.":"HTML is not ready yet.",at=({checked:e,description:n,id:t,label:s,onChange:r})=>{const i=`${t}-label`;return a.jsxs("div",{className:"flex min-h-6 items-center gap-2",children:[a.jsx(ht,{id:t,size:"sm",checked:e,onChange:c=>r(c.target.checked),"aria-labelledby":i}),a.jsx("label",{id:i,htmlFor:t,className:"min-w-0 cursor-pointer",children:a.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",className:"block",children:s})}),a.jsx(mn,{content:a.jsx("span",{className:"block max-w-[240px] leading-4",children:n}),side:"top",children:a.jsx("button",{type:"button",className:"focus-ring-soft inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-secondary","aria-label":`${s} help`,children:a.jsx(Un,{className:"h-3.5 w-3.5"})})})]})};function _r({isOpen:e,metadata:n,getHtml:t,getMarkdown:s,onClose:r}){const i=Re(),[c,l]=o.useState("html"),[p,u]=o.useState(!0),[h,x]=o.useState(!1),[m,d]=o.useState(!1),v=Bt(c,p),b=async()=>{d(!0);try{const S=await Mr({format:c,includeAssets:p,includeMetadata:h,metadata:n,source:{getHtml:t,getMarkdown:s}});if(S.type==="not-ready"){i(Pr(S.format));return}Dr(S.blob,S.filename),r(),i("Downloaded note.")}catch{i("Failed to download note.")}finally{d(!1)}};return a.jsxs(M,{isOpen:e,onClose:r,variant:"compact",children:[a.jsx(M.Header,{title:"Download document",onClose:r}),a.jsx(M.Body,{children:a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsxs("div",{className:"flex flex-col gap-3",role:"radiogroup","aria-label":"Format",children:[a.jsx(N,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Format"}),a.jsxs("div",{className:"flex flex-wrap gap-4",children:[a.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[a.jsx("input",{type:"radio",name:"note-export-format",value:"html",checked:c==="html",onChange:()=>l("html"),className:"h-4 w-4 accent-cta"}),a.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".html"})]}),a.jsxs("label",{className:"flex cursor-pointer items-center gap-2",children:[a.jsx("input",{type:"radio",name:"note-export-format",value:"markdown",checked:c==="markdown",onChange:()=>l("markdown"),className:"h-4 w-4 accent-cta"}),a.jsx(N,{as:"span",variant:"label",weight:"medium",tone:"secondary",children:".md"})]})]})]}),a.jsxs("div",{className:"flex flex-col gap-3",role:"group","aria-label":"Options",children:[a.jsx(N,{as:"span",variant:"meta",weight:"bold",tone:"muted",children:"Options"}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(at,{id:"note-export-include-assets",label:"Include local image assets",checked:p,onChange:u,description:"Bundle uploaded Ocean Brain images with the document. Without assets, local images are omitted."}),a.jsx(at,{id:"note-export-include-metadata",label:"Include metadata",checked:h,onChange:x,description:"Add the note title, note id, timestamps, and Ocean Brain source information."})]})]})]})}),a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{variant:"ghost",size:"sm",onClick:r,children:"Cancel"}),a.jsx(T,{variant:"primary",size:"sm",onClick:b,disabled:m,children:m?"Downloading...":`Download .${v}`})]})})]})}const Lt=e=>e==="mcp"?{actor:"An MCP client",place:"through MCP",target:"the MCP update"}:e==="web"?{actor:"Another browser tab",place:"in another tab",target:"the tab update"}:{actor:"Another editor",place:"elsewhere",target:"the outside change"},Or=({isDeleted:e,isConflict:n,source:t})=>{const s=Lt(t);return e?`This note was moved to trash ${s.place}`:n?`Save paused: note changed ${s.place}`:`This note changed ${s.place}`},Br=({isDeleted:e,isConflict:n,hasDraft:t,source:s})=>{const r=Lt(s);return e?`${r.actor} moved this note to trash. Open trash to review or restore it.`:n&&t?`Your draft is saved locally. Reload the latest note, overwrite ${r.target}, or clone your draft into a new note.`:n?`The layout change is paused because the note changed ${r.place}. Reload the latest note or overwrite only the layout.`:`${r.actor} changed this note while it was open here. Reload the latest version before continuing.`};function Lr({isOpen:e,isDeleted:n,isConflict:t,hasDraft:s,source:r,isReloading:i,onReload:c,onOverwrite:l,onCloneDraft:p,onOpenTrash:u}){return a.jsxs(M,{isOpen:e,onClose:()=>{},variant:"inspect",children:[a.jsx(M.Header,{title:Or({isDeleted:n,isConflict:t,source:r})}),a.jsx(M.Body,{children:a.jsx(N,{as:"p",variant:"body",tone:"secondary",className:"leading-6",children:Br({isDeleted:n,isConflict:t,hasDraft:s,source:r})})}),a.jsx(M.Footer,{children:a.jsx(xe,{children:n?a.jsx(T,{type:"button",variant:"primary",size:"sm",onClick:u,children:"Open trash"}):t?a.jsxs(a.Fragment,{children:[a.jsx(T,{type:"button",variant:"subtle",size:"sm",isLoading:i,onClick:c,children:"Reload latest"}),s&&a.jsx(T,{type:"button",variant:"ghost",size:"sm",onClick:p,children:"Clone draft"}),a.jsx(T,{type:"button",variant:"danger",size:"sm",onClick:l,children:"Overwrite"})]}):a.jsx(T,{type:"button",variant:"primary",size:"sm",isLoading:i,onClick:c,children:"Reload latest"})})})]})}function Fr({localDraftCreatedAt:e,hasSaveError:n,onRestoreDraft:t,onDiscardDraft:s,onRetrySave:r,onSaveAsNewNote:i}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(tt,{tone:"danger",className:"mb-6",children:a.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[a.jsxs("span",{children:["A draft from ",e," is saved only in this browser."]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(T,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:t,children:"Restore draft"}),a.jsx(T,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:s,children:"Discard"})]})]})}),n&&a.jsx(tt,{tone:"danger",className:"mb-6",children:a.jsxs("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[a.jsx("span",{children:"Save failed. Your latest draft is still available here. Retry before leaving this note."}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(T,{type:"button",size:"sm",variant:"subtle",className:"self-start",onClick:r,children:"Retry save"}),a.jsx(T,{type:"button",size:"sm",variant:"ghost",className:"self-start",onClick:i,children:"Save as new note"})]})]})})]})}const st=(e,n)=>e||(n==="mobile"?"Mobile browser":n==="mcp"?"MCP":"Web browser");function $r({isOpen:e,noteId:n,onClose:t,restoreSnapshot:s=mt,onRestored:r}){const i=Re(),c=Ke(),[l,p]=o.useState(null),[u,h]=o.useState("diff"),x=o.useRef(null),m=$e({queryKey:E.notes.snapshots(n),queryFn:async()=>{const f=await gn(n);if(f.type==="error")throw f;return f.noteSnapshots},enabled:e}),d=On({mutationFn:s,onSuccess:async f=>{if(f){if(f.type==="error"){i(f.errors[0].message);return}await Promise.all([c.invalidateQueries({queryKey:E.notes.detail(n),exact:!0}),c.invalidateQueries({queryKey:E.notes.listAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.tagListAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.tagNameListAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.pinned(),exact:!0}),c.invalidateQueries({queryKey:E.notes.backReferencesAll(),exact:!1}),c.invalidateQueries({queryKey:E.notes.graph(),exact:!0}),c.invalidateQueries({queryKey:E.notes.snapshots(n),exact:!1}),c.invalidateQueries({queryKey:E.views.sectionNotesAll(),exact:!1}),c.invalidateQueries({queryKey:E.tags.all(),exact:!1})]),i("Previous version restored."),r?.(f.restoreNoteSnapshot),p(null),t()}}}),v=m.data?.find(f=>f.id===l)??null,b=$e({queryKey:[...E.notes.snapshotDetail(l??"pending"),"diff"],queryFn:async()=>{if(!l)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await xn(l,"current");if(f.type==="error")throw f;if(!f.noteSnapshotDiff)throw new Error("SNAPSHOT_DIFF_NOT_FOUND");return f.noteSnapshotDiff},enabled:!!l&&u==="diff"}),S=$e({queryKey:E.notes.snapshotDetail(l??"pending"),queryFn:async()=>{if(!l)throw new Error("SNAPSHOT_NOT_SELECTED");const f=await vn(l);if(f.type==="error")throw f;if(!f.noteSnapshot)throw new Error("SNAPSHOT_NOT_FOUND");return f.noteSnapshot},enabled:!!l&&u==="content"}),j=S.data?.contentAsMarkdown.trim()??"";o.useEffect(()=>{l&&x.current?.focus()},[l]);const A=(f,y)=>{h(y),p(f)},w=()=>{p(null),h("diff"),t()};return a.jsxs(M,{isOpen:e,onClose:w,variant:"inspect",children:[a.jsx(M.Header,{title:v?u==="diff"?"Snapshot Diff":"Snapshot Content":"Restore Previous Version",onClose:w}),a.jsx(M.Description,{className:"sr-only",children:v?u==="diff"?"Review the markdown diff between this snapshot and the current note.":"Read this snapshot content before restoring it.":"Choose a previous snapshot to restore."}),a.jsx(M.Body,{children:v?a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsx(N,{as:"p",variant:"body",weight:"semibold",truncate:!0,children:v.title}),a.jsxs(N,{as:"p",variant:"label",tone:"tertiary",children:["Before"," ",st(v.meta.label,v.meta.entrypoint)," ","edit - ",Q(v.createdAt).format("YYYY-MM-DD HH:mm:ss")]})]}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsx(T,{variant:u==="diff"?"primary":"subtle",size:"sm",onClick:()=>h("diff"),children:"Show diff"}),a.jsx(T,{variant:u==="content"?"primary":"subtle",size:"sm",onClick:()=>h("content"),children:"View content"})]}),u==="diff"?b.isLoading?a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot diff..."}):b.isError?a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot diff could not be loaded."}):b.data?a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(N,{as:"p",variant:"meta",tone:"secondary",children:"Changes from this snapshot to the current note. Red lines were in the snapshot; green lines are in the current note."}),a.jsx("pre",{className:"max-h-[60vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-0 py-3 text-xs leading-5 text-fg-secondary",children:b.data.diff.markdown.split(`
20
+ `).map((f,y)=>{const D=f.startsWith("+")&&!f.startsWith("+++")?"bg-emerald-500/12 text-emerald-700 dark:text-emerald-200":f.startsWith("-")&&!f.startsWith("---")?"bg-rose-500/12 text-rose-700 dark:text-rose-200":f.startsWith("@@")?"bg-sky-500/12 text-sky-700 dark:text-sky-200":"text-fg-secondary";return a.jsx("span",{className:`block min-w-full whitespace-pre-wrap break-words px-4 ${D}`,children:f||" "},`${y}-${f}`)})})]}):null:S.isLoading?a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Loading snapshot content..."}):S.isError?a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"Snapshot content could not be loaded."}):j?a.jsx("pre",{className:"max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3 text-sm leading-6 text-fg-secondary",children:j}):a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"No readable content was found for this snapshot."})]}):a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsx(N,{as:"p",variant:"meta",tone:"secondary",children:"Choose a previous snapshot to restore this note back to that state."}),m.isLoading&&a.jsx(N,{as:"div",variant:"meta",tone:"secondary",children:"Loading previous versions..."}),!m.isLoading&&m.data?.length===0&&a.jsx(N,{as:"div",variant:"meta",tone:"secondary",className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-4 py-3",children:"A recovery snapshot appears before the first edit in a session. Up to 10 recent snapshots are kept for 7 days, and identical versions are skipped."}),!m.isLoading&&m.data&&m.data.length>0&&a.jsx("div",{className:"flex flex-col gap-2",children:m.data.map(f=>a.jsx(Kn,{padding:"compact",children:a.jsxs("div",{className:"flex flex-col gap-3",children:[a.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs(N,{as:"p",variant:"body",weight:"semibold",children:["Before"," ",st(f.meta.label,f.meta.entrypoint)," ","edit"]}),a.jsx(N,{as:"p",variant:"meta",truncate:!0,tone:"secondary",children:f.title}),a.jsx(N,{as:"p",variant:"label",tone:"tertiary",children:Q(f.createdAt).format("YYYY-MM-DD HH:mm:ss")})]}),a.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2 sm:justify-end",children:[a.jsx(T,{variant:"subtle",size:"sm",onClick:()=>A(f.id,"diff"),children:"Compare"}),a.jsx(T,{size:"sm",isLoading:d.isPending,onClick:()=>d.mutate(f.id),children:"Restore"})]})]}),f.contentPreview&&a.jsx("div",{className:"rounded-[14px] border border-border-subtle bg-hover-subtle/50 px-3 py-2",children:a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"line-clamp-4 whitespace-pre-wrap break-words",children:f.contentPreview})})]})},f.id))})]})}),v&&a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{ref:x,variant:"subtle",onClick:()=>{p(null),h("diff")},children:"Back"}),a.jsx(T,{isLoading:d.isPending,onClick:()=>d.mutate(v.id),children:"Restore this version"})]})})]})}const ot={low:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},medium:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"},high:{active:"border-border-secondary bg-elevated text-fg-default",inactive:"border-transparent bg-transparent text-fg-muted hover:bg-hover-subtle"}};function Ur({isOpen:e,onClose:n,onSave:t,reminder:s,mode:r}){const[i,c]=o.useState(new Date),[l,p]=o.useState("medium"),[u,h]=o.useState("");o.useEffect(()=>{e&&r==="edit"&&s?(c(new Date(Number(s.reminderDate))),p(s.priority||"medium"),h(s.content||"")):e&&r==="create"&&(c(new Date),p("medium"),h(""))},[e,r,s]);const x=()=>{t(i,l,u||void 0),n()},m=d=>l===d?ot[d].active:ot[d].inactive;return a.jsxs(M,{isOpen:e,onClose:n,variant:"form",children:[a.jsx(M.Header,{title:r==="create"?"Create Reminder":"Edit Reminder",onClose:n}),a.jsx(M.Body,{children:a.jsxs("div",{className:"flex flex-col gap-3 sm:gap-4",children:[a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Le,{children:"Date & Time"}),a.jsx(yn,{type:"datetime-local",size:"sm",value:Q(i).format("YYYY-MM-DDTHH:mm"),onChange:d=>c(new Date(d.target.value))})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Le,{children:"Content"}),a.jsx(bn,{size:"sm",placeholder:"Enter reminder content (optional)",value:u,onChange:d=>h(d.target.value)})]}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Le,{children:"Priority"}),a.jsxs(wn,{type:"single",variant:"quiet",value:l,onValueChange:d=>d&&p(d),className:"gap-1.5 border-none rounded-[14px] bg-muted/70 p-1 sm:gap-2",children:[a.jsx(Fe,{value:"low",className:`flex-1 rounded-[10px] border ${m("low")}`,children:a.jsx(N,{as:"span",weight:"medium",className:"text-current",children:"Low"})}),a.jsx(Fe,{value:"medium",className:`flex-1 rounded-[10px] border ${m("medium")}`,children:a.jsx(N,{as:"span",weight:"medium",className:"text-current",children:"Medium"})}),a.jsx(Fe,{value:"high",className:`flex-1 rounded-[10px] border ${m("high")}`,children:a.jsx(N,{as:"span",weight:"medium",className:"text-current",children:"High"})})]})]})]})}),a.jsx(M.Footer,{children:a.jsxs(xe,{children:[a.jsx(T,{variant:"ghost",size:"sm",onClick:n,children:"Cancel"}),a.jsx(T,{variant:"primary",size:"sm",onClick:x,children:r==="create"?"Create":"Save"})]})})]})}function Hr({noteId:e}){const[n,t]=o.useState(!1),[s,r]=o.useState(!1),[i,c]=o.useState("create"),[l,p]=o.useState(void 0),{onCreate:u,onUpdate:h,onDelete:x}=Yn(),m=()=>{c("create"),p(void 0),r(!0)},d=w=>{c("edit"),p(w),r(!0)},v=(w,f,y)=>{i==="create"?u(e,w,f,()=>{r(!1)},y):i==="edit"&&l&&h(l.id,e,{reminderDate:w,priority:f,content:y},()=>{r(!1)})},b=w=>{h(w.id,e,{completed:!w.completed})},S=w=>{const f=Q(Number(w)),y=Q();return f.isSame(y,"day")?`Today at ${f.format("HH:mm")}`:f.isSame(y.add(1,"day"),"day")?`Tomorrow at ${f.format("HH:mm")}`:f.format("YYYY-MM-DD HH:mm")},j=w=>{const f=Q(Number(w)),y=Q(),D=f.diff(y,"hour");return D<=6?"high":D<=24?"medium":"low"},A=w=>{const f=Q(Number(w)),y=Q(),D=f.diff(y,"hour"),F=f.diff(y,"minute")%60;return D<0||F<0?"Overdue":D===0?`${F}m remaining`:`${D}h ${F}m remaining`};return a.jsxs(a.Fragment,{children:[a.jsx(wt,{title:"Reminders",icon:a.jsx(Bn,{className:"h-3.5 w-3.5"}),action:a.jsxs(a.Fragment,{children:[!n&&a.jsxs(T,{size:"sm",variant:"ghost",onClick:m,children:[a.jsx(Qn,{className:"w-3 h-3"}),a.jsx(N,{as:"span",variant:"label",className:"hidden sm:inline",children:"Add"})]}),a.jsxs(T,{type:"button",size:"sm",variant:"ghost","aria-label":n?"Expand reminders":"Collapse reminders","aria-expanded":!n,onClick:()=>t(!n),children:[n?a.jsx(Cn,{className:"h-3.5 w-3.5"}):a.jsx(Nn,{className:"h-3.5 w-3.5"}),n?"Expand":"Collapse"]})]}),children:!n&&a.jsx(qn,{noteId:e,searchParams:{offset:0,limit:9999},render:({reminders:w,totalCount:f})=>a.jsx("div",{className:"flex flex-col gap-2",children:w.length===0?a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"py-3 text-center",children:f===0?"No reminders yet":"All reminders complete"}):a.jsx("div",{className:"flex flex-col",children:w.map(y=>{const D=y.priority||j(y.reminderDate),F=A(y.reminderDate),P=F==="Overdue";return a.jsxs("div",{className:J("flex items-center gap-2.5 px-2 py-1.5"),children:[a.jsx(ht,{checked:y.completed,onChange:()=>b(y),size:"sm","aria-label":`Reminder: ${y.content||S(y.reminderDate)}`}),a.jsx(N,{as:"div",variant:"body",weight:"medium",className:J("truncate flex-1 min-w-0",y.completed&&"line-through opacity-40"),children:y.content||S(y.reminderDate)}),a.jsxs("div",{className:J("shrink-0 flex items-center gap-1",y.completed&&"opacity-40"),children:[y.content&&a.jsx(N,{as:"span",variant:"meta",tone:"secondary",children:S(y.reminderDate)}),!y.completed&&a.jsx(N,{as:"span",variant:"label",weight:"medium",tone:P||D==="high"?"error":"tertiary",className:J(y.content&&'before:content-["·"] before:mr-1'),children:F})]}),a.jsx(pt,{button:a.jsx(xt,{label:"Reminder actions"}),items:[{name:"Edit",onClick:()=>d(y)},{name:"Delete",onClick:()=>x(y.id,e)}]})]},y.id)})})})})}),a.jsx(Ur,{isOpen:s,onClose:()=>r(!1),onSave:v,reminder:l,mode:i})]})}const Ir=({editor:e})=>a.jsx(Ge,{triggerCharacter:"/",getItems:async n=>tr([...Gn(e).filter(t=>t.title!=="Audio"&&t.title!=="Video"&&t.title!=="File"),{title:"Table of Contents",subtext:"Insert a table of contents based on headings",onItemClick:()=>{e.insertBlocks([{type:"tableOfContents"}],e.getTextCursorPosition().block,"after")},aliases:["toc","table of contents","contents","outline","index"],group:"Other",icon:a.jsx(vt,{})}],n)}),Vr=(e,n)=>n?e.filter(t=>t.id!==n):e,zr=({currentNoteId:e,onClick:n})=>a.jsx(Ge,{triggerCharacter:"[",getItems:async t=>{const s=await Sn({query:t,limit:5});return s.type==="error"?[]:Vr(s.allNotes.notes,e).map(i=>({title:i.title,onItemClick:()=>n({type:"reference",props:{id:i.id,title:i.title}})}))}}),Ft=["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/avif"],Wr=new Set(Ft),it="Unsupported image type. Use PNG, JPEG, GIF, WebP, BMP, or AVIF.",Kr="Failed to upload image.",Yr=e=>Wr.has(e),qr="pointer-events-auto inline-flex h-7 cursor-pointer select-none items-center gap-1.5 rounded-[8px] border border-white/10 bg-white/10 px-2.5 text-xs font-medium text-white/60 opacity-75 shadow-[0_8px_18px_-14px_rgba(0,0,0,0.45)] backdrop-blur-sm transition-colors hover:bg-white/20 hover:text-white/90 hover:opacity-100 focus-ring-soft focus:text-white/90 focus:opacity-100",Qr={idle:"",copied:"text-accent-success hover:text-accent-success focus:text-accent-success",failed:"text-fg-error hover:text-fg-error focus:text-fg-error"},Gr={idle:"Copy",copied:"Copied",failed:"Copy failed"},Zr=({getText:e,resetDelayMs:n=2e3})=>{const[t,s]=o.useState("idle"),r=o.useRef(null),i=o.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),c=o.useCallback(()=>{i(),r.current=setTimeout(()=>{s("idle"),r.current=null},n)},[i,n]);o.useEffect(()=>i,[i]);const l=h=>{h.stopPropagation()},p=h=>{h.preventDefault(),h.stopPropagation()},u=async h=>{l(h);try{await navigator.clipboard.writeText(e()),s("copied")}catch{s("failed")}c()};return a.jsx("div",{className:"pointer-events-none absolute right-3 top-2 z-[1]",contentEditable:!1,onMouseDown:p,children:a.jsxs("button",{type:"button",className:J(qr,Qr[t]),contentEditable:!1,onClick:u,children:[a.jsx(ar,{className:"h-3.5 w-3.5"}),a.jsx("span",{"aria-live":"polite",children:Gr[t]})]})})},Jr=({contentRef:e})=>{const n=o.useRef(null),t=o.useCallback(s=>{n.current=s,e(s)},[e]);return a.jsxs(a.Fragment,{children:[a.jsx("pre",{children:a.jsx("code",{ref:t})}),a.jsx(Zr,{getText:()=>n.current?.textContent?.trimEnd()??""})]})},Xr="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-[color-mix(in_srgb,var(--elevated)_72%,var(--hover-subtle))] px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-elevated hover:text-fg-default dark:bg-[color-mix(in_srgb,var(--elevated)_82%,var(--hover-subtle))]",ea={type:"reference",propSchema:{id:{default:""},title:{default:"Unknown"}},content:"none"};function ta(e){const n=gt(),t=()=>{e.editor.blur(),n({to:Ae,params:{id:e.inlineContent.props.id}})},s=r=>{r.preventDefault(),r.stopPropagation()};return a.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:Xr,onMouseDown:s,onClick:r=>{s(r),t()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),t())},children:a.jsxs("span",{children:["[",e.inlineContent.props.title,"]"]})})}const na=Ct(ea,{render:e=>a.jsx(ta,{...e})}),ra=()=>{const e=Zn(),[n,t]=o.useState([]),s={1:"pl-3",2:"pl-[26px]",3:"pl-[40px]",4:"pl-[54px]",5:"pl-[68px]",6:"pl-[82px]"};o.useEffect(()=>{const c=()=>{const p=e.document,u=[],h=x=>{for(const m of x){if(m.type==="heading"){const d=m,v=d.props.level||1,b=d.content?.map(S=>S.text||"").join("")||"";b.trim()&&u.push({id:m.id,level:v,text:b})}m.children&&Array.isArray(m.children)&&h(m.children)}};h(p),t(u)};c();const l=e.onChange?.(c);return()=>{l&&l()}},[e]);const r=c=>{e.setTextCursorPosition(c);const l=document.querySelector(`[data-id="${c}"]`);if(l){const p=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;l.scrollIntoView({behavior:p?"auto":"smooth",block:"center"})}},i=a.jsx(Hn,{icon:a.jsx(vt,{className:"h-3.5 w-3.5"}),title:"Table of Contents",className:"text-fg-tertiary"});return n.length===0?a.jsxs("div",{className:"surface-base w-full p-4",children:[i,a.jsx(N,{as:"p",variant:"meta",tone:"secondary",className:"mt-2",children:"Add headings to your document to generate a table of contents"})]}):a.jsxs("div",{className:"surface-base w-full p-4",children:[a.jsx("div",{className:"mb-2",children:i}),a.jsx("nav",{className:"space-y-0.5",children:n.map(c=>{const l=c.level===1;return a.jsxs("button",{type:"button",onClick:()=>r(c.id),className:J("focus-ring-soft","flex","w-full","items-center","gap-2","rounded-[10px]","px-2.5","py-1.5",s[c.level]??"pl-2.5","text-left","transition-colors","hover:bg-hover-subtle",l?"text-fg-default":"text-fg-secondary"),children:[a.jsxs(N,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"min-w-[1.5rem]",children:["H",c.level]}),a.jsx(N,{as:"span",variant:"body",weight:l?"semibold":"medium",className:"line-clamp-2 text-current",children:c.text})]},c.id)})})]})},aa=Nt({type:"tableOfContents",propSchema:{},content:"none"},{render:()=>a.jsx(ra,{})})(),sa="focus-ring-soft inline-flex cursor-pointer items-center rounded-[8px] border border-border-subtle bg-emphasis px-2 py-0.5 text-xs font-semibold text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover-subtle hover:text-fg-default dark:bg-emphasis",oa={type:"tag",propSchema:{id:{default:""},tag:{default:"@Unknown"}},content:"none"};function ia(e){const n=gt(),t=()=>{e.editor.blur(),n({to:zn,params:{id:e.inlineContent.props.id},search:{page:1}})},s=r=>{r.preventDefault(),r.stopPropagation()};return a.jsx("span",{role:"link",tabIndex:0,contentEditable:!1,className:sa,onMouseDown:s,onClick:r=>{s(r),t()},onKeyDown:r=>{r.key!=="Enter"&&r.key!==" "||(s(r),t())},children:a.jsx("span",{children:e.inlineContent.props.tag})})}const ca=Ct(oa,{render:e=>a.jsx(ia,{...e})}),la=e=>e,da=e=>e,ua=la({tag:ca,reference:na}),fa=da({tableOfContents:aa}),ce=me.codeBlock,ct=Nt(ce.config,{meta:ce.implementation.meta,parse:ce.implementation.parse,parseContent:ce.implementation.parseContent,runsBefore:ce.implementation.runsBefore,render:Jr})(),pa={...ct,extensions:ce.extensions,implementation:{...ct.implementation,toExternalHTML:ce.implementation.toExternalHTML}},ha={...me.image,implementation:{...me.image.implementation,meta:{...me.image.implementation.meta,fileBlockAccept:[...Ft]}}},ma=nr.create({inlineContentSpecs:{...rr,...ua},blockSpecs:{...me,image:ha,codeBlock:pa,...fa}}),ga=(e,n)=>n.some(t=>t.name===`@${e}`),xa=({onClick:e})=>a.jsx(Ge,{triggerCharacter:"@",getItems:async n=>{const t=await sr({query:n,limit:5});if(t.type==="error")return[];const{tags:s}=t.allTags,r=ga(n,s),i=[{title:"Add a new tag",onItemClick:async()=>{const c=await or({name:"@"+n});if(c.type==="error")return;const{id:l,name:p}=c.createTag;e({type:"tag",props:{id:l,tag:p}})}}];return s.length===0?i:s.map(c=>({title:c.name,onItemClick:()=>e({type:"tag",props:{id:c.id,tag:c.name}})})).concat(n&&!r?i:[])}}),va=/^ {0,3}(`{3,}|~{3,})/,ya=/<[^<>\n]*>/g,$t=/~+/g,Ut=/[\p{L}\p{M}\p{N}\p{Sc}%‰.,+\-/:°℃℉µμ·²³^]/u,We=new RegExp("^(?:[+-]?\\p{Sc}?|\\p{Sc}[+-]?)\\p{N}","u"),Ht=/&#(?:x[0-9a-f]+|\d+);/giu,ba=new Set(["Files","blocknote/html","vscode-editor-data"]),lt="OBTILDE",dt="",wa=[/(^|\n) {0,3}#{1,6} {1,8}[^\n]{1,64}\r?\n\r?\n\s{0,32}\S/,/(_|__|\*|\*\*|~~|==|\+\+)(?!\s)(?:[^\s](?:.{0,62}[^\s])?|\S)(?=\1)/,/\[[^\]]{1,128}\]\(https?:\/\/\S{1,999}\)/,/(?:\s|^)`(?!\s)(?:[^\s`](?:[^`]{0,46}[^\s`])?|[^\s`])`([^\w]|$)/,/(?:^|\n)\s{0,5}-\s{1}[^\n]+\n\s{0,15}-\s/,/(?:^|\n)\s{0,5}\d+\.\s{1}[^\n]+\n\s{0,15}\d+\.\s/,/\n{2} {0,3}-{2,48}\n{2}/,/(?:\n|^)(```|~~~|\$\$)(?!`|~)[^\s]{0,64} {0,64}[^\n]{0,64}\n[\s\S]{0,9999}?\s*\1 {0,64}(?:\n+|$)/,/(?:\n|^)(?!\s)\w[^\n]{0,64}\n(-|=)\1{0,64}\n\n\s{0,64}(\w|$)/,/(?:^|(\r?\n\r?\n))( {0,3}>[^\n]{1,333}\n){1,999}($|(\r?\n))/],Ca=e=>e.split(`
21
+ `).some(n=>{const t=n.trim();return t.length>2&&t.startsWith("|")&&t.endsWith("|")}),Na=e=>wa.some(n=>n.test(e))||Ca(e),Sa=e=>e.endsWith(`\r
22
+ `)?{body:e.slice(0,-2),ending:`\r
23
+ `}:e.endsWith(`
24
+ `)||e.endsWith("\r")?{body:e.slice(0,-1),ending:e.slice(-1)}:{body:e,ending:""},It=(e,n,t)=>{let s=n;for(;e[s]===t;)s+=1;return s-n},Vt=e=>{const n=e.slice(2,-1),t=n[0]?.toLowerCase()==="x",s=Number.parseInt(t?n.slice(1):n,t?16:10);return!Number.isSafeInteger(s)||s<0||s>1114111?e:String.fromCodePoint(s)},ja=e=>{const n=e.replace(Ht,Vt),t=e.toLowerCase();let s=0,r=`${lt}${s}${dt}`;for(;e.includes(r)||t.includes(encodeURIComponent(r).toLowerCase())||n.includes(r);)s+=1,r=`${lt}${s}${dt}`;return r},Ra=(e,n,t)=>t-n>2?!1:zt(e,n)&&ka(e,t),ut=(e,n)=>{let t=n;for(;t>0&&Ut.test(e[t-1]??"");)t-=1;return{start:t,token:e.slice(t,n)}},Aa=(e,n)=>{let t=n;for(;t<e.length&&Ut.test(e[t]??"");)t+=1;return e.slice(n,t)},zt=(e,n)=>{const t=ut(e,n);if(We.test(t.token))return!0;if(!t.token)return!1;let s=t.start;for(;s>0&&(e[s-1]===" "||e[s-1]===" ");)s-=1;return s===t.start?!1:We.test(ut(e,s).token)},ka=(e,n)=>We.test(Aa(e,n)),Wt=e=>{const n=[],t=new Set;for(const s of e.matchAll($t)){const r=s.index,i=s[0].length,c=r+i;if(i>2)continue;const l=c<e.length&&!/\s/u.test(e[c]??""),p=r>0&&!/\s/u.test(e[r-1]??"");if(Ra(e,r,c)){if(p&&t.delete(i))continue;n.push({length:i,start:r});continue}p&&t.delete(i)||l&&zt(e,r)&&t.add(i)}return n},Ue=(e,n)=>{let t="",s=0;const r=new Set(Wt(e).map(i=>i.start));for(const i of e.matchAll($t)){const c=i.index,l=c+i[0].length;t+=e.slice(s,c),t+=r.has(c)?n.repeat(i[0].length):i[0],s=l}return t+e.slice(s)},Ea=e=>{const n=e.slice(1,-1),t=/^[a-z][a-z0-9.+-]{1,31}:[^\s<>]*$/i.test(n)||/^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(n),s=/^<\/?[a-z][\w:-]*(?:\s[^<>]*)?\/?\s*>$/i.test(e)||/^<![^<>]*>$/.test(e);return t||s},Ta=(e,n)=>{let t="",s=0;for(const r of e.matchAll(ya)){const i=r.index;t+=Ue(e.slice(s,i),n),t+=Ea(r[0])?r[0]:Ue(r[0],n),s=i+r[0].length}return t+Ue(e.slice(s),n)},Kt=e=>Wt(e).length>0,Da=e=>{if(!Kt(e))return nt(e);const n=ja(e),t=Ta(e,n),s=encodeURIComponent(n);return nt(t).split(n).join("~").split(s).join("~")},Ma=(e,n)=>{let t=0;for(let s=n-1;s>=0&&e[s]==="\\";s-=1)t+=1;return t%2===1},Pa=(e,n,t)=>{let s=n+t;for(;s<e.length;){const r=e.indexOf("`",s);if(r===-1)return null;const i=It(e,r,"`");if(i===t)return r+i;s=r+i}return null},_a=(e,n)=>{let t=e.indexOf("`",n);for(;t!==-1;){const s=It(e,t,"`");if(!Ma(e,t)){const r=Pa(e,t,s);if(r!==null)return{start:t,end:r}}t=e.indexOf("`",t+s)}return null},Oa=(e,n)=>{let t="",s=0;for(;s<e.length;){const r=_a(e,s);if(!r){t+=n(e.slice(s));break}t+=n(e.slice(s,r.start)),t+=e.slice(r.start,r.end),s=r.end}return t},Yt=(e,n)=>{let t=null;return e.split(new RegExp("(?<=\\n)")).map(s=>{const{body:r,ending:i}=Sa(s);if(t)return new RegExp(`^ {0,3}${t.marker}{${t.length},} *$`).test(r)&&(t=null),s;const c=r.match(va)?.[1];return c?(t={marker:c[0],length:c.length},s):`${Oa(r,n)}${i}`}).join("")},Ba=(e,n)=>{let t=0;for(let s=n;s<e.length;s+=1){const r=e[s];if(r==="\\"){s+=1;continue}if(r==="("){t+=1;continue}if(r===")"){if(t>0){t-=1;continue}return s}}return null},qt=e=>{let n="",t=0;for(;t<e.length;){const s=e.indexOf("](",t);if(s===-1){n+=e.slice(t);break}const r=s+2,i=Ba(e,r);if(i===null){n+=e.slice(t);break}n+=e.slice(t,r),n+=e.slice(r,i).split("\\&").join("&"),n+=")",t=i+1}return n},La=(e,n)=>{const t=e[n-1];if(t!=="*"&&t!=="_")return!1;let s=n-1;for(;s>0&&e[s-1]===t;)s-=1;const r=e.slice(s,n),i=e.lastIndexOf(r,s-1);return i!==-1&&i+r.length<s},Fa=(e,n)=>{const t=e[n];if(t!=="*"&&t!=="_")return!1;let s=n+1;for(;s<e.length&&e[s]===t;)s+=1;const r=e.slice(n,s),i=e.indexOf(r,s);return i!==-1&&s<i},$a=(e,n,t)=>La(e,n)||Fa(e,n+t),Ua=e=>Yt(e,n=>{const t=n.replace(Ht,(s,r,i)=>$a(i,r,s.length)?Vt(s):s);return qt(t)}),Ha=e=>Yt(e,qt),Ia=e=>{const n=e.getData("text/plain");n&&(e.setData("text/markdown",n),e.setData("text/plain",Ua(n)))},Va=({event:e,editor:n,defaultPasteHandler:t})=>{const s=e.clipboardData;if(!s||n.getTextCursorPosition().block.type==="codeBlock")return t();const r=Array.from(s.types);if(r.some(l=>ba.has(l)))return t();const i=r.includes("text/markdown"),c=s.getData(i?"text/markdown":"text/plain");return!c||!Kt(c)||!i&&r.includes("text/html")&&!Na(c)?t():(n.pasteHTML(Da(c)),!0)},za=new Set(["tableOfContents"]),Wa="OCEAN_BRAIN_TAG_",Ka="_TOKEN",Ya=e=>`${Wa}${e}${Ka}`,qa=e=>!Array.isArray(e)&&e?.type==="tableContent",Qa=(e,n)=>Array.isArray(e)?e.map(n):qa(e)?{...e,rows:e.rows?.map(t=>({...t,cells:t.cells?.map(s=>({...s,content:s.content?.map(n)}))}))}:e,Qt=(e,n)=>e.filter(t=>!za.has(t.type)).map(t=>({...t,content:n(t.content),children:t.children?.length?Qt(t.children,n):[]}));function Ga(e){const n=new Map;let t=0;return{blocks:Qt(e,r=>Qa(r,i=>{if(i.type==="reference"){const c=String(i.props?.id||""),l=String(i.props?.title||i.props?.id||"");return{type:"text",text:c?`[[${l}]](note:${c})`:`[[${l}]]`,styles:{}}}if(i.type==="tag"){const c=i.props?.tag||"",l=Ya(t);return t+=1,n.set(l,c),{type:"text",text:l,styles:{}}}return i})),placeholderToTag:n}}function Za(e,n){let t=e;for(const[s,r]of n.entries())t=t.split(s).join(`[${r}]`);return t}async function Ja(e){return new Promise((n,t)=>{const s=new FileReader;s.readAsDataURL(e),s.onload=()=>n(s.result),s.onerror=r=>t(r)})}const Xa=o.forwardRef(({content:e,currentNoteId:n,editable:t,onChange:s},r)=>{const{theme:i}=jn(u=>u),c=Re(),l=Jn({schema:ma,initialContent:e&&JSON.parse(e)||void 0,pasteHandler:u=>Va(u),uploadFile:async(u,h)=>{const x=()=>{h&&l.getBlock(h)&&l.removeBlocks([h])};if(!Yr(u.type))throw x(),c(it),new Error(it);try{return await er({base64:await Ja(u)})}catch(m){throw x(),c(Kr),m}}},[c]);o.useImperativeHandle(r,()=>({getContent:()=>JSON.stringify(l.document),getMarkdown:()=>{const u=Ga(l.document),h=l.blocksToMarkdownLossy(u.blocks);return Ha(Za(h,u.placeholderToTag))},getHtml:()=>l.blocksToHTMLLossy(l.document)}));const p=u=>{Ia(u.clipboardData)};return a.jsxs(Xn,{slashMenu:!1,theme:i,editor:l,editable:t,onChange:s,onCopy:p,onCut:p,children:[a.jsx(Ir,{editor:l}),a.jsx(zr,{currentNoteId:n,onClick:u=>{l.insertInlineContent([u," "])}}),a.jsx(xa,{onClick:u=>{l.insertInlineContent([u," "])}})]})}),es=({event:e,noteId:n,editSessionId:t,loadedUpdatedAt:s,acceptedUpdatedAt:r,hasUnsavedChanges:i})=>{if(e.noteId!==n||e.type==="mcp.note.created")return{type:"ignore"};if(e.source==="web"&&e.editSessionId===t)return{type:"ignore"};if(e.type==="mcp.note.deleted")return{type:"notify",change:{type:"deleted",source:e.source},shouldPauseSave:!1};const c=Se(e.updatedAt,s),l=Se(e.updatedAt,r);return c!==null&&c<=0||l!==null&&l<=0?{type:"ignore"}:{type:"notify",change:{type:"updated",updatedAt:e.updatedAt,source:e.source},shouldPauseSave:i}},ts=({change:e,isConflict:n,loadedUpdatedAt:t})=>e?!(e.type==="updated"&&!n&&e.updatedAt===t):!1;function ns({allowNextNavigationRef:e,hasExternalPendingChanges:n,saveStatus:t,flushPendingChanges:s,notify:r}){const i=o.useCallback(async()=>{if(e.current)return e.current=!1,!1;if(t==="conflict")return r("Resolve the note conflict before leaving."),!0;const c=await s();return c==="error"?(r("Save failed. Stay on this note and try again."),!0):c==="conflict"},[e,s,r,t]);cr({disabled:t==="saved"&&!n,enableBeforeUnload:!1,shouldBlockFn:i})}const Je=e=>`ocean-brain.note-draft.${e}`,rs=e=>{if(typeof window>"u")return null;try{const n=window.localStorage.getItem(Je(e));if(!n)return null;const t=JSON.parse(n);return typeof t.title!="string"||typeof t.content!="string"||typeof t.baseUpdatedAt!="string"?null:{title:t.title,content:t.content,baseUpdatedAt:t.baseUpdatedAt,createdAt:typeof t.createdAt=="number"?t.createdAt:Date.now(),...t.layout==="narrow"||t.layout==="wide"||t.layout==="full"?{layout:t.layout}:{}}}catch{return null}},He=(e,n)=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Je(e),JSON.stringify(n))}catch{}},Ie=e=>{if(!(typeof window>"u"))try{window.localStorage.removeItem(Je(e))}catch{}},as=1e3,ss="NOTE_UPDATE_CONFLICT";function os({noteId:e,initialContent:n,initialUpdatedAt:t,editSessionIdRef:s,getContent:r,beforeSave:i,hasExternalPendingChanges:c,serverVersionRef:l,executeWrite:p,onSaved:u,onConflict:h,onError:x}){const m=Ke(),d=o.useRef(null),v=o.useRef(null),b=o.useRef(!1),S=o.useRef(null),j=o.useRef(!1),A=o.useRef(t),w=l??A,f=o.useRef(0),y=o.useRef(!1),D=o.useRef(!0),F=o.useRef(u),P=o.useRef(h),W=o.useRef(x),ve=o.useRef(i),X=o.useRef(c),he=o.useRef(p),[re,ee]=o.useState("saved"),[Ee,le]=o.useState(null),$=o.useCallback(()=>{d.current!==null&&(window.clearTimeout(d.current),d.current=null)},[]),B=o.useCallback(k=>{D.current&&ee(k)},[]),Te=o.useCallback(k=>{w.current=k},[]),ye=o.useCallback((k,L={})=>({title:k,content:r()??n,createdAt:Date.now(),baseUpdatedAt:w.current,...L.layout?{layout:L.layout}:{}}),[r,n]),de=o.useCallback(()=>{v.current&&He(e,v.current)},[e]),ae=o.useCallback(k=>{y.current=!0,B("conflict"),P.current(k??w.current)},[B]),O=o.useCallback(async({ignoreConflict:k=!1,silent:L=!1}={})=>{if(b.current)return j.current=!0,S.current??"idle";const Me=v.current!==null,se=X.current?.()??!1;if(!Me&&!se)return j.current=!1,"idle";const U=f.current;j.current=!1,$(),b.current=!0,L||B("saving");const H=(async()=>{const ue=await ve.current?.()??"idle";if(U!==f.current)return"idle";if(ue==="error")return b.current=!1,S.current=null,v.current?B("error"):B("saved"),"error";const _=v.current;if(!_)return b.current=!1,S.current=null,B("saved"),ue;v.current=null;const q=async()=>{if(U!==f.current)return"idle";let z;try{z=await ze({id:e,title:_.title,content:_.content,..._.layout?{layout:_.layout}:{},editSessionId:s.current,...k?{force:!0}:{expectedUpdatedAt:w.current}})}catch{z={type:"error",category:"network",errors:[{code:"NETWORK_ERROR",message:"Failed to save note."}]}}if(U!==f.current)return"idle";if(z.type==="error"){b.current=!1,S.current=null,v.current||(v.current=_),de();const I=z.errors[0];if(I.code===ss&&!k){const oe=I.details?.extensions?.currentUpdatedAt;return y.current=!0,!L&&D.current&&(B("conflict"),P.current(oe??w.current)),"conflict"}return!L&&D.current&&(B("error"),W.current(I.message)),"error"}const we=!L&&D.current,Z=E.notes.detail(e);if(await m.cancelQueries({queryKey:Z,exact:!0}),U!==f.current)return"idle";b.current=!1,S.current=null,y.current=!1,w.current=z.updateNote.updatedAt,we&&F.current(z.updateNote.updatedAt),m.setQueryData(Z,I=>I&&{...I,title:z.updateNote.title,content:_.content,..._.layout?{layout:_.layout}:{},updatedAt:z.updateNote.updatedAt}),yt({noteId:e,updatedAt:z.updateNote.updatedAt,editSessionId:s.current});const fe=v.current;return fe?.baseUpdatedAt===_.baseUpdatedAt?(v.current={...fe,baseUpdatedAt:z.updateNote.updatedAt},de()):fe||Ie(e),we&&(v.current?ee("pending"):(ee("saved"),m.invalidateQueries({queryKey:E.notes.listAll(),exact:!1}),m.invalidateQueries({queryKey:E.notes.tagListAll(),exact:!1}),m.invalidateQueries({queryKey:E.notes.backReferencesAll(),exact:!1}),m.invalidateQueries({queryKey:E.notes.graph(),exact:!0}))),"saved"},V=he.current?await he.current(q):await q();return V?V==="saved"&&(v.current||j.current)?O({silent:L}):V:(v.current||(v.current=_),de(),b.current=!1,S.current=null,B("pending"),"idle")})();return S.current=H,H},[$,s,e,de,m,w,B]),te=o.useCallback((k,L={})=>{if(v.current=k,He(e,k),y.current){B("conflict");return}if(B("pending"),$(),L.immediate){O();return}d.current=window.setTimeout(()=>{O()},as)},[$,O,e,B]),ne=o.useCallback(k=>{if(v.current=k,He(e,k),le(null),k.baseUpdatedAt!==w.current){ae(w.current);return}te(k)},[e,te,ae]),be=o.useCallback(()=>{f.current+=1,$(),v.current=null,b.current=!1,S.current=null,j.current=!1,y.current=!1,Ie(e),le(null),ee("saved")},[$,e]),De=o.useCallback(()=>{$(),S.current=null,j.current=!1,y.current=!1,B(v.current?"pending":"saved")},[$,B]),G=o.useCallback(()=>{Ie(e),le(null)},[e]),Y=o.useCallback(()=>v.current,[]),K=o.useCallback(k=>{$(),ae(k)},[$,ae]);return o.useEffect(()=>{ve.current=i,he.current=p,X.current=c,P.current=h,W.current=x,F.current=u},[i,p,c,h,x,u]),o.useEffect(()=>(D.current=!0,()=>{D.current=!1}),[]),o.useEffect(()=>{v.current||b.current||y.current||(w.current=t,ee("saved"))},[t]),o.useEffect(()=>{f.current+=1,v.current=null,b.current=!1,S.current=null,j.current=!1,y.current=!1,w.current=t,le(rs(e)),ee("saved")},[e]),o.useEffect(()=>{const k=L=>{!v.current&&!b.current&&!y.current&&!X.current?.()||(L.preventDefault(),L.returnValue="")};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[]),o.useEffect(()=>()=>{$(),v.current&&!y.current&&O({silent:!0})},[$,O]),{saveStatus:re,localDraft:Ee,serverUpdatedAtRef:w,hasUnsavedChanges:re!=="saved",buildDraft:ye,queueSave:te,flushPendingSave:O,restoreLocalDraft:ne,discardLocalDraft:G,clearDrafts:be,resolveConflict:De,pauseForConflict:K,getPendingDraft:Y,setServerUpdatedAt:Te}}function is(){const e=o.useRef(Promise.resolve()),n=o.useRef(0),t=o.useRef(0),[s,r]=o.useState(!1),i=o.useCallback(u=>{t.current+=1,r(!0);const h=n.current,x=()=>h===n.current?u():void 0,m=e.current.then(x,x);e.current=m.then(()=>{},()=>{});const d=()=>{t.current-=1,t.current===0&&r(!1)};return m.then(d,d),m},[]),c=o.useCallback(()=>{n.current+=1},[]),l=o.useCallback(()=>e.current,[]),p=o.useCallback(()=>t.current>0,[]);return o.useMemo(()=>({execute:i,invalidatePending:c,drain:l,isBusy:s,hasPendingWrites:p}),[l,i,p,c,s])}const cs="NOTE_UPDATE_CONFLICT",Ve=e=>{const n=ge(e);return Q(n??Number(e)).format("YYYY-MM-DD HH:mm:ss")},ls=e=>e?.extensions?.currentUpdatedAt;function ds({noteId:e,navigateToNote:n,notify:t}){const s=Ke(),r=o.useRef(null),i=o.useRef(null),[c]=o.useState(rt),l=o.useRef(c),p=o.useRef(null),u=o.useRef(null),h=o.useRef(!1),x=o.useRef(0),m=ft({queryKey:E.notes.detail(e),queryFn:async()=>{const g=await Rn(e);if(g.type==="error")throw g;return g.note},gcTime:0}),d=m.data,v=m.refetch,b=o.useRef(d.updatedAt),S=o.useRef(d.updatedAt),[j,A]=o.useState(d.title),[w,f]=o.useState(d.pinned),[y,D]=o.useState(d.layout||"wide"),F=o.useRef(y),[P,W]=o.useState(null),[ve,X]=o.useState(null),[he,re]=o.useState(0),[ee,Ee]=o.useState(()=>Ve(d.updatedAt)),[le,$]=o.useState(d.updatedAt),[B,Te]=o.useState(0),[ye,de]=o.useState(!1),ae=o.useRef(!1),{execute:O,invalidatePending:te,drain:ne,isBusy:be,hasPendingWrites:De}=is(),G=o.useCallback(g=>{F.current=g,D(g)},[]),Y=o.useCallback((g,C={})=>{b.current=g,S.current=g,Ee(Ve(g)),$(g),C.confirmSave&&Te(R=>R+1)},[]),K=o.useCallback(async({updatedAt:g,patch:C,confirmSave:R=!0})=>{const pe=E.notes.detail(e),Oe=x.current;return await s.cancelQueries({queryKey:pe,exact:!0}),Oe!==x.current?!1:(Y(g,{confirmSave:R}),s.setQueryData(pe,Be=>Be&&{...Be,...C,updatedAt:g}),yt({noteId:e,updatedAt:g,editSessionId:l.current}),!0)},[Y,e,s]),k=o.useCallback(g=>{ae.current=g,de(g)},[]),L=o.useCallback(()=>p.current?.flushPendingSave({expectedUpdatedAt:b.current})??Promise.resolve("idle"),[]),Me=os({noteId:e,initialContent:d.content,initialUpdatedAt:d.updatedAt,editSessionIdRef:l,serverVersionRef:b,executeWrite:O,getContent:()=>r.current?.getContent(),beforeSave:L,hasExternalPendingChanges:()=>ae.current||De(),onSaved:g=>{u.current=null,Y(g,{confirmSave:!0})},onConflict:g=>{W({type:"updated",updatedAt:g,source:"unknown"}),t("This note changed elsewhere. Choose how to resolve the draft.")},onError:t}),{saveStatus:se,localDraft:U,serverUpdatedAtRef:H,hasUnsavedChanges:ue,buildDraft:_,queueSave:q,flushPendingSave:V,restoreLocalDraft:z,discardLocalDraft:we,clearDrafts:Z,resolveConflict:fe,pauseForConflict:I,getPendingDraft:oe}=Me,Ce=ue||ye||be,Xe=o.useCallback(async g=>{const C=await V(g);return C==="error"||C==="conflict"||await ne(),C},[ne,V]),Zt=o.useCallback(g=>O(async()=>{const C=await An({...g,expectedUpdatedAt:b.current});return C.type==="success"&&await K({updatedAt:C.updateNoteProperties.updatedAt,patch:{properties:C.updateNoteProperties.properties}}),C}),[K,O]);ns({allowNextNavigationRef:h,hasExternalPendingChanges:ye||be,saveStatus:se,flushPendingChanges:Xe,notify:t}),o.useEffect(()=>{if(Ce){d.updatedAt!==H.current&&(Se(d.updatedAt,H.current)??0)>0&&I(d.updatedAt);return}const g=S.current;if(!(g&&d.updatedAt!==g&&(Se(d.updatedAt,g)??0)<0)&&(f(d.pinned),G(d.layout||"wide"),A(d.title),g!==d.updatedAt)){const C=r.current?.getContent();Y(d.updatedAt),(C===void 0||C!==d.content)&&(X(null),re(R=>R+1))}},[Y,Ce,d.content,d.layout,d.pinned,d.title,d.updatedAt,I,H]),o.useEffect(()=>{P?.type!=="updated"||se==="conflict"||P.updatedAt!==d.updatedAt||(Y(d.updatedAt),W(null))},[Y,P,d.updatedAt,se]),o.useEffect(()=>Ln(g=>{const C=es({event:g,noteId:e,editSessionId:l.current,loadedUpdatedAt:d.updatedAt,acceptedUpdatedAt:H.current,hasUnsavedChanges:Ce});C.type!=="ignore"&&(C.shouldPauseSave&&C.change.type==="updated"&&I(C.change.updatedAt),W(C.change))}),[Ce,d.updatedAt,e,I,H]);const Jt=o.useCallback(()=>{q(_(j))},[_,q,j]),Xt=o.useCallback(g=>{A(g),q(_(g))},[_,q]),en=o.useCallback(()=>{q(_(j),{immediate:!0})},[_,q,j]),tn=o.useCallback(async g=>{if(ue){G(g),q(_(j,{layout:g}),{immediate:!0}),t("Layout will be saved with your draft.");return}const C=await V();C==="error"||C==="conflict"||await O(async()=>{const R=await ze({id:e,layout:g,editSessionId:l.current,expectedUpdatedAt:H.current});if(R.type==="error"){R.errors[0].code===cs&&(u.current=g,G(g),I(ls(R.errors[0].details)??H.current)),t(R.errors[0].message);return}await K({updatedAt:R.updateNote.updatedAt,patch:{layout:g}})&&(u.current=null,G(g),t("Layout has been updated."))})},[K,_,O,V,ue,e,t,I,q,H,j]),nn=o.useCallback(async()=>{const g=await V();if(g==="error"||g==="conflict")return;const C=!w;await O(async()=>{const R=await kn(e,C);if(R.type==="error"){t(R.errors[0].message);return}await K({updatedAt:R.pinNote.updatedAt,patch:{pinned:C},confirmSave:!1})&&(f(C),await Promise.all([s.invalidateQueries({queryKey:E.notes.listAll(),exact:!1}),s.invalidateQueries({queryKey:E.notes.tagListAll(),exact:!1}),s.invalidateQueries({queryKey:E.notes.pinned(),exact:!0})]))})},[K,O,V,w,e,t,s]),Pe=o.useCallback(()=>({id:e,title:j,createdAt:d.createdAt,updatedAt:H.current||d.updatedAt}),[d.createdAt,d.updatedAt,e,H,j]),rn=o.useCallback(async()=>{const g=r.current?.getMarkdown();if(g===void 0){t("Markdown is not ready yet.");return}try{await navigator.clipboard.writeText(Pt(g,Pe())),t("Copied note as Markdown.")}catch{t("Failed to copy Markdown.")}},[Pe,t]),an=o.useCallback(async()=>{p.current?.invalidateInFlightSave(),te(),await ne(),x.current+=1;const g=await v();if(g.error||!g.data){t("Failed to reload the latest note state.");return}p.current?.discardPendingChanges(),Z(),u.current=null,Y(g.data.updatedAt),A(g.data.title),G(g.data.layout||"wide"),X(null),re(C=>C+1),W(null)},[Z,Y,ne,te,t,v]),sn=o.useCallback(async()=>{if(oe()){u.current=null,W(null),await V({ignoreConflict:!0});return}const C=u.current;if(!C){W(null),await V({ignoreConflict:!0});return}await O(async()=>{const R=await ze({id:e,layout:C,editSessionId:l.current,force:!0});if(R.type==="error"){t(R.errors[0].message);return}await K({updatedAt:R.updateNote.updatedAt,patch:{layout:C}})&&(u.current=null,fe(),W(null),G(C))})},[K,O,V,oe,e,t,fe]),on=o.useCallback(async()=>{const g=oe();if(!g||await L()==="error")return;const R=await En({title:et(g.title||"untitled"),content:et(g.content),layout:g.layout??y});if(R.type==="error"){t(R.errors[0].message);return}h.current=!0,u.current=null,W(null),Z(),Promise.resolve(n(R.createNote.id)).finally(()=>{h.current=!1})},[Z,L,oe,y,n,t]),cn=o.useCallback(()=>{U&&(A(U.title),U.layout&&G(U.layout),X(U.content),re(g=>g+1),z(U))},[U,z]),ln=o.useCallback(()=>{},[]),dn=o.useCallback(async g=>(p.current?.invalidateInFlightSave(),te(),await ne(),x.current+=1,O(async()=>{const C=await mt(g);if(C.type==="error")return C;const R=C.restoreNoteSnapshot;return await K({updatedAt:R.updatedAt,patch:{title:R.title,content:R.content,layout:R.layout,pinned:R.pinned}})&&(l.current=rt(),p.current?.discardPendingChanges(),Z(),u.current=null,W(null),A(R.title),G(R.layout||"wide"),f(R.pinned),X(R.content),re(Oe=>Oe+1)),C})),[K,Z,ne,O,te]),_e=se==="conflict"&&P?.type==="updated",un=_e?oe():null;return{document:{title:j,titleRef:i,isPinned:w,layout:y,getLayout:()=>F.current,properties:d.properties,createdAt:Ve(d.createdAt),onTitleChange:Xt,onLayoutSave:tn,onTogglePinned:nn},editor:{ref:r,key:`${e}:${he}`,content:ve??d.content,getContent:()=>r.current?.getContent()??"",getHtml:()=>r.current?.getHtml(),getMarkdown:()=>r.current?.getMarkdown(),onChange:Jt},save:{status:se,lastSavedAt:ee,lastSavedVersion:le,confirmationRevision:B,onManualSave:en,flushPendingChanges:Xe},recovery:{localDraftCreatedAt:U?Q(U.createdAt).format("YYYY-MM-DD HH:mm:ss"):null,onRestoreLocalDraft:cn,onDiscardLocalDraft:we,onClonePendingDraft:on},externalChange:{value:P,isConflict:_e,hasConflictDraft:un!==null,isBlocking:ts({change:P,isConflict:_e,loadedUpdatedAt:d.updatedAt}),isReloading:m.isRefetching,onReload:an,onOverwrite:sn},properties:{ref:p,expectedUpdatedAt:H.current,editSessionId:l.current,saveProperties:Zt,onPendingChange:k,onSaved:ln},exportDocument:{metadata:Pe(),onCopyMarkdown:rn},snapshots:{restore:dn}}}const Gt=Tn(Ae),us={narrow:"max-w-[640px]",wide:"max-w-[896px]",full:"max-w-full px-4"},fs=a.jsx(qe,{title:"Loading note",variant:"none",children:a.jsxs("main",{className:"mx-auto max-w-[896px]",children:[a.jsx(ie,{className:"mb-8",height:123}),a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx(ie,{height:135}),a.jsx(ie,{className:"ml-12",height:320}),a.jsx(ie,{height:107}),a.jsx(ie,{height:100})]})]})});function ps({noteId:e}){return a.jsx(Ye,{fallback:a.jsx(ie,{height:107}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading reminder details for this note.",renderError:({error:n,retry:t})=>a.jsx(Qe,{title:"Failed to load reminders",description:"Retry loading reminder details for this note.",error:n,onRetry:t,showBackAction:!1,showHomeAction:!1}),children:a.jsx(Hr,{noteId:e})})}function hs({noteId:e}){return a.jsx(Ye,{fallback:a.jsx(ie,{height:100}),errorTitle:"Failed to load back references",errorDescription:"Retry loading notes that link back here.",renderError:({error:n,retry:t})=>a.jsx(Qe,{title:"Failed to load back references",description:"Retry loading notes that link back here.",error:n,onRetry:t,showBackAction:!1,showHomeAction:!1}),children:a.jsx(fr,{noteId:e,render:n=>n?.length?a.jsx(wt,{icon:a.jsx(Vn,{className:"h-3.5 w-3.5"}),title:"Back References",children:a.jsx("ul",{className:"flex flex-col",children:n.map(t=>a.jsx("li",{children:a.jsxs(Dn,{to:Ae,params:{id:t.id},className:"flex items-center gap-2 rounded-[10px] px-2.5 py-1.5 text-fg-secondary transition-colors hover:bg-hover-subtle hover:text-fg-default",children:[a.jsx(dr,{className:"h-3.5 w-3.5 shrink-0 text-fg-tertiary"}),a.jsx(N,{as:"span",variant:"body",weight:"medium",className:"text-current",children:t.title})]})},t.id))})}):null})})}function ms({id:e}){const n=Re(),t=Gt.useNavigate(),[s,r]=o.useState(!1),[i,c]=o.useState(!1),[l,p]=o.useState(!1),u=ds({noteId:e,notify:n,navigateToNote:P=>t({to:Ae,params:{id:P}})}),{onCreate:h,onDelete:x,deleteWarningDialog:m}=Fn(),{document:d,editor:v,save:b,recovery:S,externalChange:j,properties:A,exportDocument:w,snapshots:f}=u,y=()=>t({to:Wn,search:{page:1}}),D=async()=>{const P=await b.flushPendingChanges();P==="error"||P==="conflict"||await x(e,y)},F=async()=>{const P=await b.flushPendingChanges();P==="error"||P==="conflict"||await h(d.titleRef.current?.value||"untitled",v.getContent(),d.getLayout())};return a.jsx(qe,{title:d.title,variant:"none",children:a.jsxs("main",{className:J("mx-auto",us[d.layout]),children:[a.jsx(xr,{title:d.title,titleRef:d.titleRef,isPinned:d.isPinned,createdAt:d.createdAt,saveStatus:b.status,savedAt:b.lastSavedAt,savedVersion:b.lastSavedVersion,saveConfirmationRevision:b.confirmationRevision,onTitleChange:d.onTitleChange,onCopyMarkdown:()=>{w.onCopyMarkdown()},onDownloadDocument:()=>p(!0),onTogglePinned:()=>{d.onTogglePinned()},onChangeLayout:()=>r(!0),onCloneNote:()=>{F()},onRestoreVersion:()=>c(!0),onDelete:()=>{D()},onSave:b.onManualSave}),a.jsx(Fr,{localDraftCreatedAt:S.localDraftCreatedAt,hasSaveError:b.status==="error",onRestoreDraft:S.onRestoreLocalDraft,onDiscardDraft:S.onDiscardLocalDraft,onRetrySave:b.onManualSave,onSaveAsNewNote:()=>{S.onClonePendingDraft()}}),a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsx(In,{ref:A.ref,noteId:e,properties:d.properties,expectedUpdatedAt:A.expectedUpdatedAt,editSessionId:A.editSessionId,disabled:b.status!=="saved",saveProperties:A.saveProperties,onPendingChange:A.onPendingChange,onSaved:A.onSaved}),a.jsx(Xa,{ref:v.ref,content:v.content,currentNoteId:e,onChange:v.onChange},v.key),a.jsx(ps,{noteId:e}),a.jsx(hs,{noteId:e})]}),a.jsx(hr,{isOpen:s,onClose:()=>r(!1),onSave:d.onLayoutSave,currentLayout:d.layout}),a.jsx(Lr,{isOpen:j.isBlocking,isDeleted:j.value?.type==="deleted",isConflict:j.isConflict,hasDraft:j.hasConflictDraft,source:j.value?.source??"unknown",isReloading:j.isReloading,onReload:()=>{j.onReload()},onOverwrite:()=>{j.onOverwrite()},onCloneDraft:()=>{S.onClonePendingDraft()},onOpenTrash:()=>{y()}}),a.jsx(_r,{isOpen:l,metadata:w.metadata,getHtml:v.getHtml,getMarkdown:v.getMarkdown,onClose:()=>p(!1)}),a.jsx($r,{isOpen:i,noteId:e,onClose:()=>c(!1),restoreSnapshot:f.restore}),m]})})}function Ms(){const{id:e}=Gt.useParams();if(!e)throw new Error("Note id is required.");return a.jsx(Ye,{fallback:fs,errorTitle:"Failed to load note",errorDescription:"Retry loading the note editor.",resetKeys:[e],renderError:({error:n,retry:t})=>a.jsx(qe,{title:"Note",variant:"none",children:a.jsx(Qe,{title:"Failed to load note",description:"Retry loading the note editor.",error:n,onRetry:t})}),children:a.jsx(ms,{id:e},e)})}export{ms as NoteContent,Ms as default};
@@ -0,0 +1,2 @@
1
+ import{r as et,j as q,v as zt,g as Gt}from"./floating-ui.react-dom-wWLZ1CdM.js";import{d as Yt,h as qt,n as Vt}from"./time-B3pt8vt4.js";import{R as Xt,Z as _t,a5 as Ct,U as Jt,T as Nt,aM as $t,_ as Dt,a0 as It,aw as jt,au as kt,a7 as Qt,b7 as te,b8 as ee,b9 as re,ba as ne,bb as ie,bc as ae,ad as Ft,a8 as se,ax as oe}from"./note.api-D_00ZzJC.js";import{i as Pt}from"./url-BSnWpmJx.js";import{n as Lt}from"./Plus.es-CQ8wn2is.js";const le=new Map([["bold",et.createElement(et.Fragment,null,et.createElement("path",{d:"M87.5,151.52l64-64a12,12,0,0,1,17,17l-64,64a12,12,0,0,1-17-17Zm131-114a60.08,60.08,0,0,0-84.87,0L103.51,67.61a12,12,0,0,0,17,17l30.07-30.06a36,36,0,0,1,50.93,50.92L171.4,135.52a12,12,0,1,0,17,17l30.08-30.06A60.09,60.09,0,0,0,218.45,37.55ZM135.52,171.4l-30.07,30.08a36,36,0,0,1-50.92-50.93l30.06-30.07a12,12,0,0,0-17-17L37.55,133.58a60,60,0,0,0,84.88,84.87l30.06-30.07a12,12,0,0,0-17-17Z"}))],["duotone",et.createElement(et.Fragment,null,et.createElement("path",{d:"M209.94,113.94l-96,96a48,48,0,0,1-67.88-67.88l96-96a48,48,0,0,1,67.88,67.88Z",opacity:"0.2"}),et.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["fill",et.createElement(et.Fragment,null,et.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM144.56,173.66l-21.45,21.45a44,44,0,0,1-62.22-62.22l21.45-21.46a8,8,0,0,1,11.32,11.31L72.2,144.2a28,28,0,0,0,39.6,39.6l21.45-21.46a8,8,0,0,1,11.31,11.32Zm-34.9-16a8,8,0,0,1-11.32-11.32l48-48a8,8,0,0,1,11.32,11.32Zm85.45-34.55-21.45,21.45a8,8,0,0,1-11.32-11.31L183.8,111.8a28,28,0,0,0-39.6-39.6L122.74,93.66a8,8,0,0,1-11.31-11.32l21.46-21.45a44,44,0,0,1,62.22,62.22Z"}))],["light",et.createElement(et.Fragment,null,et.createElement("path",{d:"M164.25,91.75a6,6,0,0,1,0,8.49l-64,64a6,6,0,0,1-8.49-8.48l64-64A6,6,0,0,1,164.25,91.75ZM214.2,41.8a54.07,54.07,0,0,0-76.38,0L107.75,71.85a6,6,0,0,0,8.49,8.49l30.07-30.06a42,42,0,0,1,59.41,59.41l-30.08,30.07a6,6,0,1,0,8.49,8.49l30.07-30.07A54,54,0,0,0,214.2,41.8ZM139.76,175.64l-30.07,30.08a42,42,0,0,1-59.41-59.41l30.06-30.07a6,6,0,0,0-8.49-8.49l-30,30.07a54,54,0,0,0,76.38,76.39l30.07-30.08a6,6,0,0,0-8.49-8.49Z"}))],["regular",et.createElement(et.Fragment,null,et.createElement("path",{d:"M165.66,90.34a8,8,0,0,1,0,11.32l-64,64a8,8,0,0,1-11.32-11.32l64-64A8,8,0,0,1,165.66,90.34ZM215.6,40.4a56,56,0,0,0-79.2,0L106.34,70.45a8,8,0,0,0,11.32,11.32l30.06-30a40,40,0,0,1,56.57,56.56l-30.07,30.06a8,8,0,0,0,11.31,11.32L215.6,119.6a56,56,0,0,0,0-79.2ZM138.34,174.22l-30.06,30.06a40,40,0,1,1-56.56-56.57l30.05-30.05a8,8,0,0,0-11.32-11.32L40.4,136.4a56,56,0,0,0,79.2,79.2l30.06-30.07a8,8,0,0,0-11.32-11.31Z"}))],["thin",et.createElement(et.Fragment,null,et.createElement("path",{d:"M162.84,93.16a4,4,0,0,1,0,5.66l-64,64a4,4,0,0,1-5.66-5.66l64-64A4,4,0,0,1,162.84,93.16Zm49.95-49.95a52.07,52.07,0,0,0-73.56,0L109.17,73.27a4,4,0,0,0,5.65,5.66l30.07-30.06a44,44,0,0,1,62.24,62.24l-30.07,30.06a4,4,0,0,0,5.66,5.66l30.07-30.06A52.07,52.07,0,0,0,212.79,43.21ZM141.17,177.06l-30.06,30.07a44,44,0,0,1-62.24-62.24l30.06-30.06a4,4,0,0,0-5.66-5.66L43.21,139.23a52,52,0,0,0,73.56,73.56l30.06-30.07a4,4,0,1,0-5.66-5.66Z"}))]]),Zt=et.forwardRef((it,ht)=>et.createElement(Xt,{ref:ht,...it,weights:le}));Zt.displayName="LinkSimpleIcon";const ue=Zt;function he({icon:it,title:ht,className:p}){return q.jsxs("div",{className:Ct("flex items-center gap-2",p),children:[q.jsx("div",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center text-current",children:it}),q.jsx(_t,{as:"span",variant:"label",weight:"semibold",className:"text-current",children:ht})]})}function ce({title:it,icon:ht,action:p,titleButtonProps:D,ariaLabel:b,className:o,children:l}){const n=l!=null&&l!==!1,h=p!=null&&p!==!1,v=q.jsx(he,{icon:ht,title:it,className:"text-fg-tertiary"});return q.jsxs("section",{className:Ct("surface-base p-4",o),"aria-label":b??it,children:[q.jsxs("div",{className:Ct("relative",h&&"pr-44 sm:pr-48",n&&"mb-3"),children:[D?q.jsx("button",{...D,type:"button",className:Ct("focus-ring-soft -m-1 flex items-center gap-2 rounded-[10px] p-1 text-fg-tertiary transition-colors hover:bg-hover-subtle hover:text-fg-default",D.className),children:v}):v,h&&q.jsx("div",{className:"absolute top-1/2 right-0 flex -translate-y-1/2 items-center gap-2",children:p})]}),l]})}function Et(it){throw new Error('Could not dynamically require "'+it+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Rt={exports:{}};var Ut;function fe(){return Ut||(Ut=1,(function(it,ht){(function(p){it.exports=p()})(function(){return(function p(D,b,o){function l(v,k){if(!b[v]){if(!D[v]){var _=typeof Et=="function"&&Et;if(!k&&_)return _(v,!0);if(n)return n(v,!0);var g=new Error("Cannot find module '"+v+"'");throw g.code="MODULE_NOT_FOUND",g}var i=b[v]={exports:{}};D[v][0].call(i.exports,function(f){var r=D[v][1][f];return l(r||f)},i,i.exports,p,D,b,o)}return b[v].exports}for(var n=typeof Et=="function"&&Et,h=0;h<o.length;h++)l(o[h]);return l})({1:[function(p,D,b){var o=p("./utils"),l=p("./support"),n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";b.encode=function(h){for(var v,k,_,g,i,f,r,u=[],a=0,d=h.length,w=d,z=o.getTypeOf(h)!=="string";a<h.length;)w=d-a,_=z?(v=h[a++],k=a<d?h[a++]:0,a<d?h[a++]:0):(v=h.charCodeAt(a++),k=a<d?h.charCodeAt(a++):0,a<d?h.charCodeAt(a++):0),g=v>>2,i=(3&v)<<4|k>>4,f=1<w?(15&k)<<2|_>>6:64,r=2<w?63&_:64,u.push(n.charAt(g)+n.charAt(i)+n.charAt(f)+n.charAt(r));return u.join("")},b.decode=function(h){var v,k,_,g,i,f,r=0,u=0,a="data:";if(h.substr(0,a.length)===a)throw new Error("Invalid base64 input, it looks like a data url.");var d,w=3*(h=h.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(h.charAt(h.length-1)===n.charAt(64)&&w--,h.charAt(h.length-2)===n.charAt(64)&&w--,w%1!=0)throw new Error("Invalid base64 input, bad content length.");for(d=l.uint8array?new Uint8Array(0|w):new Array(0|w);r<h.length;)v=n.indexOf(h.charAt(r++))<<2|(g=n.indexOf(h.charAt(r++)))>>4,k=(15&g)<<4|(i=n.indexOf(h.charAt(r++)))>>2,_=(3&i)<<6|(f=n.indexOf(h.charAt(r++))),d[u++]=v,i!==64&&(d[u++]=k),f!==64&&(d[u++]=_);return d}},{"./support":30,"./utils":32}],2:[function(p,D,b){var o=p("./external"),l=p("./stream/DataWorker"),n=p("./stream/Crc32Probe"),h=p("./stream/DataLengthProbe");function v(k,_,g,i,f){this.compressedSize=k,this.uncompressedSize=_,this.crc32=g,this.compression=i,this.compressedContent=f}v.prototype={getContentWorker:function(){var k=new l(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new h("data_length")),_=this;return k.on("end",function(){if(this.streamInfo.data_length!==_.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),k},getCompressedWorker:function(){return new l(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},v.createWorkerFrom=function(k,_,g){return k.pipe(new n).pipe(new h("uncompressedSize")).pipe(_.compressWorker(g)).pipe(new h("compressedSize")).withStreamInfo("compression",_)},D.exports=v},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(p,D,b){var o=p("./stream/GenericWorker");b.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},b.DEFLATE=p("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(p,D,b){var o=p("./utils"),l=(function(){for(var n,h=[],v=0;v<256;v++){n=v;for(var k=0;k<8;k++)n=1&n?3988292384^n>>>1:n>>>1;h[v]=n}return h})();D.exports=function(n,h){return n!==void 0&&n.length?o.getTypeOf(n)!=="string"?(function(v,k,_,g){var i=l,f=g+_;v^=-1;for(var r=g;r<f;r++)v=v>>>8^i[255&(v^k[r])];return-1^v})(0|h,n,n.length,0):(function(v,k,_,g){var i=l,f=g+_;v^=-1;for(var r=g;r<f;r++)v=v>>>8^i[255&(v^k.charCodeAt(r))];return-1^v})(0|h,n,n.length,0):0}},{"./utils":32}],5:[function(p,D,b){b.base64=!1,b.binary=!1,b.dir=!1,b.createFolders=!0,b.date=null,b.compression=null,b.compressionOptions=null,b.comment=null,b.unixPermissions=null,b.dosPermissions=null},{}],6:[function(p,D,b){var o=null;o=typeof Promise<"u"?Promise:p("lie"),D.exports={Promise:o}},{lie:37}],7:[function(p,D,b){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",l=p("pako"),n=p("./utils"),h=p("./stream/GenericWorker"),v=o?"uint8array":"array";function k(_,g){h.call(this,"FlateWorker/"+_),this._pako=null,this._pakoAction=_,this._pakoOptions=g,this.meta={}}b.magic="\b\0",n.inherits(k,h),k.prototype.processChunk=function(_){this.meta=_.meta,this._pako===null&&this._createPako(),this._pako.push(n.transformTo(v,_.data),!1)},k.prototype.flush=function(){h.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},k.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this._pako=null},k.prototype._createPako=function(){this._pako=new l[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var _=this;this._pako.onData=function(g){_.push({data:g,meta:_.meta})}},b.compressWorker=function(_){return new k("Deflate",_)},b.uncompressWorker=function(){return new k("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(p,D,b){function o(i,f){var r,u="";for(r=0;r<f;r++)u+=String.fromCharCode(255&i),i>>>=8;return u}function l(i,f,r,u,a,d){var w,z,S=i.file,R=i.compression,O=d!==v.utf8encode,L=n.transformTo("string",d(S.name)),I=n.transformTo("string",v.utf8encode(S.name)),M=S.comment,V=n.transformTo("string",d(M)),m=n.transformTo("string",v.utf8encode(M)),T=I.length!==S.name.length,e=m.length!==M.length,N="",J="",U="",Q=S.dir,Z=S.date,$={crc32:0,compressedSize:0,uncompressedSize:0};f&&!r||($.crc32=i.crc32,$.compressedSize=i.compressedSize,$.uncompressedSize=i.uncompressedSize);var C=0;f&&(C|=8),O||!T&&!e||(C|=2048);var y=0,G=0;Q&&(y|=16),a==="UNIX"?(G=798,y|=(function(F,st){var ut=F;return F||(ut=st?16893:33204),(65535&ut)<<16})(S.unixPermissions,Q)):(G=20,y|=(function(F){return 63&(F||0)})(S.dosPermissions)),w=Z.getUTCHours(),w<<=6,w|=Z.getUTCMinutes(),w<<=5,w|=Z.getUTCSeconds()/2,z=Z.getUTCFullYear()-1980,z<<=4,z|=Z.getUTCMonth()+1,z<<=5,z|=Z.getUTCDate(),T&&(J=o(1,1)+o(k(L),4)+I,N+="up"+o(J.length,2)+J),e&&(U=o(1,1)+o(k(V),4)+m,N+="uc"+o(U.length,2)+U);var K="";return K+=`
2
+ \0`,K+=o(C,2),K+=R.magic,K+=o(w,2),K+=o(z,2),K+=o($.crc32,4),K+=o($.compressedSize,4),K+=o($.uncompressedSize,4),K+=o(L.length,2),K+=o(N.length,2),{fileRecord:_.LOCAL_FILE_HEADER+K+L+N,dirRecord:_.CENTRAL_FILE_HEADER+o(G,2)+K+o(V.length,2)+"\0\0\0\0"+o(y,4)+o(u,4)+L+N+V}}var n=p("../utils"),h=p("../stream/GenericWorker"),v=p("../utf8"),k=p("../crc32"),_=p("../signature");function g(i,f,r,u){h.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=r,this.encodeFileName=u,this.streamFiles=i,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}n.inherits(g,h),g.prototype.push=function(i){var f=i.meta.percent||0,r=this.entriesCount,u=this._sources.length;this.accumulate?this.contentBuffer.push(i):(this.bytesWritten+=i.data.length,h.prototype.push.call(this,{data:i.data,meta:{currentFile:this.currentFile,percent:r?(f+100*(r-u-1))/r:100}}))},g.prototype.openedSource=function(i){this.currentSourceOffset=this.bytesWritten,this.currentFile=i.file.name;var f=this.streamFiles&&!i.file.dir;if(f){var r=l(i,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:r.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(i){this.accumulate=!1;var f=this.streamFiles&&!i.file.dir,r=l(i,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(r.dirRecord),f)this.push({data:(function(u){return _.DATA_DESCRIPTOR+o(u.crc32,4)+o(u.compressedSize,4)+o(u.uncompressedSize,4)})(i),meta:{percent:100}});else for(this.push({data:r.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var i=this.bytesWritten,f=0;f<this.dirRecords.length;f++)this.push({data:this.dirRecords[f],meta:{percent:100}});var r=this.bytesWritten-i,u=(function(a,d,w,z,S){var R=n.transformTo("string",S(z));return _.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(a,2)+o(a,2)+o(d,4)+o(w,4)+o(R.length,2)+R})(this.dirRecords.length,r,i,this.zipComment,this.encodeFileName);this.push({data:u,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(i){this._sources.push(i);var f=this;return i.on("data",function(r){f.processChunk(r)}),i.on("end",function(){f.closedSource(f.previous.streamInfo),f._sources.length?f.prepareNextSource():f.end()}),i.on("error",function(r){f.error(r)}),this},g.prototype.resume=function(){return!!h.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},g.prototype.error=function(i){var f=this._sources;if(!h.prototype.error.call(this,i))return!1;for(var r=0;r<f.length;r++)try{f[r].error(i)}catch{}return!0},g.prototype.lock=function(){h.prototype.lock.call(this);for(var i=this._sources,f=0;f<i.length;f++)i[f].lock()},D.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(p,D,b){var o=p("../compressions"),l=p("./ZipFileWorker");b.generateWorker=function(n,h,v){var k=new l(h.streamFiles,v,h.platform,h.encodeFileName),_=0;try{n.forEach(function(g,i){_++;var f=(function(d,w){var z=d||w,S=o[z];if(!S)throw new Error(z+" is not a valid compression method !");return S})(i.options.compression,h.compression),r=i.options.compressionOptions||h.compressionOptions||{},u=i.dir,a=i.date;i._compressWorker(f,r).withStreamInfo("file",{name:g,dir:u,date:a,comment:i.comment||"",unixPermissions:i.unixPermissions,dosPermissions:i.dosPermissions}).pipe(k)}),k.entriesCount=_}catch(g){k.error(g)}return k}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(p,D,b){function o(){if(!(this instanceof o))return new o;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var l=new o;for(var n in this)typeof this[n]!="function"&&(l[n]=this[n]);return l}}(o.prototype=p("./object")).loadAsync=p("./load"),o.support=p("./support"),o.defaults=p("./defaults"),o.version="3.10.1",o.loadAsync=function(l,n){return new o().loadAsync(l,n)},o.external=p("./external"),D.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(p,D,b){var o=p("./utils"),l=p("./external"),n=p("./utf8"),h=p("./zipEntries"),v=p("./stream/Crc32Probe"),k=p("./nodejsUtils");function _(g){return new l.Promise(function(i,f){var r=g.decompressed.getContentWorker().pipe(new v);r.on("error",function(u){f(u)}).on("end",function(){r.streamInfo.crc32!==g.decompressed.crc32?f(new Error("Corrupted zip : CRC32 mismatch")):i()}).resume()})}D.exports=function(g,i){var f=this;return i=o.extend(i||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:n.utf8decode}),k.isNode&&k.isStream(g)?l.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",g,!0,i.optimizedBinaryString,i.base64).then(function(r){var u=new h(i);return u.load(r),u}).then(function(r){var u=[l.Promise.resolve(r)],a=r.files;if(i.checkCRC32)for(var d=0;d<a.length;d++)u.push(_(a[d]));return l.Promise.all(u)}).then(function(r){for(var u=r.shift(),a=u.files,d=0;d<a.length;d++){var w=a[d],z=w.fileNameStr,S=o.resolve(w.fileNameStr);f.file(S,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:i.createFolders}),w.dir||(f.file(S).unsafeOriginalName=z)}return u.zipComment.length&&(f.comment=u.zipComment),f})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(p,D,b){var o=p("../utils"),l=p("../stream/GenericWorker");function n(h,v){l.call(this,"Nodejs stream input adapter for "+h),this._upstreamEnded=!1,this._bindStream(v)}o.inherits(n,l),n.prototype._bindStream=function(h){var v=this;(this._stream=h).pause(),h.on("data",function(k){v.push({data:k,meta:{percent:0}})}).on("error",function(k){v.isPaused?this.generatedError=k:v.error(k)}).on("end",function(){v.isPaused?v._upstreamEnded=!0:v.end()})},n.prototype.pause=function(){return!!l.prototype.pause.call(this)&&(this._stream.pause(),!0)},n.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},D.exports=n},{"../stream/GenericWorker":28,"../utils":32}],13:[function(p,D,b){var o=p("readable-stream").Readable;function l(n,h,v){o.call(this,h),this._helper=n;var k=this;n.on("data",function(_,g){k.push(_)||k._helper.pause(),v&&v(g)}).on("error",function(_){k.emit("error",_)}).on("end",function(){k.push(null)})}p("../utils").inherits(l,o),l.prototype._read=function(){this._helper.resume()},D.exports=l},{"../utils":32,"readable-stream":16}],14:[function(p,D,b){D.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,l){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,l);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,l)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var l=new Buffer(o);return l.fill(0),l},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(p,D,b){function o(S,R,O){var L,I=n.getTypeOf(R),M=n.extend(O||{},k);M.date=M.date||new Date,M.compression!==null&&(M.compression=M.compression.toUpperCase()),typeof M.unixPermissions=="string"&&(M.unixPermissions=parseInt(M.unixPermissions,8)),M.unixPermissions&&16384&M.unixPermissions&&(M.dir=!0),M.dosPermissions&&16&M.dosPermissions&&(M.dir=!0),M.dir&&(S=a(S)),M.createFolders&&(L=u(S))&&d.call(this,L,!0);var V=I==="string"&&M.binary===!1&&M.base64===!1;O&&O.binary!==void 0||(M.binary=!V),(R instanceof _&&R.uncompressedSize===0||M.dir||!R||R.length===0)&&(M.base64=!1,M.binary=!0,R="",M.compression="STORE",I="string");var m=null;m=R instanceof _||R instanceof h?R:f.isNode&&f.isStream(R)?new r(S,R):n.prepareContent(S,R,M.binary,M.optimizedBinaryString,M.base64);var T=new g(S,m,M);this.files[S]=T}var l=p("./utf8"),n=p("./utils"),h=p("./stream/GenericWorker"),v=p("./stream/StreamHelper"),k=p("./defaults"),_=p("./compressedObject"),g=p("./zipObject"),i=p("./generate"),f=p("./nodejsUtils"),r=p("./nodejs/NodejsStreamInputAdapter"),u=function(S){S.slice(-1)==="/"&&(S=S.substring(0,S.length-1));var R=S.lastIndexOf("/");return 0<R?S.substring(0,R):""},a=function(S){return S.slice(-1)!=="/"&&(S+="/"),S},d=function(S,R){return R=R!==void 0?R:k.createFolders,S=a(S),this.files[S]||o.call(this,S,null,{dir:!0,createFolders:R}),this.files[S]};function w(S){return Object.prototype.toString.call(S)==="[object RegExp]"}var z={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var R,O,L;for(R in this.files)L=this.files[R],(O=R.slice(this.root.length,R.length))&&R.slice(0,this.root.length)===this.root&&S(O,L)},filter:function(S){var R=[];return this.forEach(function(O,L){S(O,L)&&R.push(L)}),R},file:function(S,R,O){if(arguments.length!==1)return S=this.root+S,o.call(this,S,R,O),this;if(w(S)){var L=S;return this.filter(function(M,V){return!V.dir&&L.test(M)})}var I=this.files[this.root+S];return I&&!I.dir?I:null},folder:function(S){if(!S)return this;if(w(S))return this.filter(function(I,M){return M.dir&&S.test(I)});var R=this.root+S,O=d.call(this,R),L=this.clone();return L.root=O.name,L},remove:function(S){S=this.root+S;var R=this.files[S];if(R||(S.slice(-1)!=="/"&&(S+="/"),R=this.files[S]),R&&!R.dir)delete this.files[S];else for(var O=this.filter(function(I,M){return M.name.slice(0,S.length)===S}),L=0;L<O.length;L++)delete this.files[O[L].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(S){var R,O={};try{if((O=n.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:l.utf8encode})).type=O.type.toLowerCase(),O.compression=O.compression.toUpperCase(),O.type==="binarystring"&&(O.type="string"),!O.type)throw new Error("No output type specified.");n.checkSupport(O.type),O.platform!=="darwin"&&O.platform!=="freebsd"&&O.platform!=="linux"&&O.platform!=="sunos"||(O.platform="UNIX"),O.platform==="win32"&&(O.platform="DOS");var L=O.comment||this.comment||"";R=i.generateWorker(this,O,L)}catch(I){(R=new h("error")).error(I)}return new v(R,O.type||"string",O.mimeType)},generateAsync:function(S,R){return this.generateInternalStream(S).accumulate(R)},generateNodeStream:function(S,R){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(R)}};D.exports=z},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(p,D,b){D.exports=p("stream")},{stream:void 0}],17:[function(p,D,b){var o=p("./DataReader");function l(n){o.call(this,n);for(var h=0;h<this.data.length;h++)n[h]=255&n[h]}p("../utils").inherits(l,o),l.prototype.byteAt=function(n){return this.data[this.zero+n]},l.prototype.lastIndexOfSignature=function(n){for(var h=n.charCodeAt(0),v=n.charCodeAt(1),k=n.charCodeAt(2),_=n.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===h&&this.data[g+1]===v&&this.data[g+2]===k&&this.data[g+3]===_)return g-this.zero;return-1},l.prototype.readAndCheckSignature=function(n){var h=n.charCodeAt(0),v=n.charCodeAt(1),k=n.charCodeAt(2),_=n.charCodeAt(3),g=this.readData(4);return h===g[0]&&v===g[1]&&k===g[2]&&_===g[3]},l.prototype.readData=function(n){if(this.checkOffset(n),n===0)return[];var h=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./DataReader":18}],18:[function(p,D,b){var o=p("../utils");function l(n){this.data=n,this.length=n.length,this.index=0,this.zero=0}l.prototype={checkOffset:function(n){this.checkIndex(this.index+n)},checkIndex:function(n){if(this.length<this.zero+n||n<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+n+"). Corrupted zip ?")},setIndex:function(n){this.checkIndex(n),this.index=n},skip:function(n){this.setIndex(this.index+n)},byteAt:function(){},readInt:function(n){var h,v=0;for(this.checkOffset(n),h=this.index+n-1;h>=this.index;h--)v=(v<<8)+this.byteAt(h);return this.index+=n,v},readString:function(n){return o.transformTo("string",this.readData(n))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var n=this.readInt(4);return new Date(Date.UTC(1980+(n>>25&127),(n>>21&15)-1,n>>16&31,n>>11&31,n>>5&63,(31&n)<<1))}},D.exports=l},{"../utils":32}],19:[function(p,D,b){var o=p("./Uint8ArrayReader");function l(n){o.call(this,n)}p("../utils").inherits(l,o),l.prototype.readData=function(n){this.checkOffset(n);var h=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(p,D,b){var o=p("./DataReader");function l(n){o.call(this,n)}p("../utils").inherits(l,o),l.prototype.byteAt=function(n){return this.data.charCodeAt(this.zero+n)},l.prototype.lastIndexOfSignature=function(n){return this.data.lastIndexOf(n)-this.zero},l.prototype.readAndCheckSignature=function(n){return n===this.readData(4)},l.prototype.readData=function(n){this.checkOffset(n);var h=this.data.slice(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./DataReader":18}],21:[function(p,D,b){var o=p("./ArrayReader");function l(n){o.call(this,n)}p("../utils").inherits(l,o),l.prototype.readData=function(n){if(this.checkOffset(n),n===0)return new Uint8Array(0);var h=this.data.subarray(this.zero+this.index,this.zero+this.index+n);return this.index+=n,h},D.exports=l},{"../utils":32,"./ArrayReader":17}],22:[function(p,D,b){var o=p("../utils"),l=p("../support"),n=p("./ArrayReader"),h=p("./StringReader"),v=p("./NodeBufferReader"),k=p("./Uint8ArrayReader");D.exports=function(_){var g=o.getTypeOf(_);return o.checkSupport(g),g!=="string"||l.uint8array?g==="nodebuffer"?new v(_):l.uint8array?new k(o.transformTo("uint8array",_)):new n(o.transformTo("array",_)):new h(_)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(p,D,b){b.LOCAL_FILE_HEADER="PK",b.CENTRAL_FILE_HEADER="PK",b.CENTRAL_DIRECTORY_END="PK",b.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",b.ZIP64_CENTRAL_DIRECTORY_END="PK",b.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(p,D,b){var o=p("./GenericWorker"),l=p("../utils");function n(h){o.call(this,"ConvertWorker to "+h),this.destType=h}l.inherits(n,o),n.prototype.processChunk=function(h){this.push({data:l.transformTo(this.destType,h.data),meta:h.meta})},D.exports=n},{"../utils":32,"./GenericWorker":28}],25:[function(p,D,b){var o=p("./GenericWorker"),l=p("../crc32");function n(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}p("../utils").inherits(n,o),n.prototype.processChunk=function(h){this.streamInfo.crc32=l(h.data,this.streamInfo.crc32||0),this.push(h)},D.exports=n},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(p,D,b){var o=p("../utils"),l=p("./GenericWorker");function n(h){l.call(this,"DataLengthProbe for "+h),this.propName=h,this.withStreamInfo(h,0)}o.inherits(n,l),n.prototype.processChunk=function(h){if(h){var v=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=v+h.data.length}l.prototype.processChunk.call(this,h)},D.exports=n},{"../utils":32,"./GenericWorker":28}],27:[function(p,D,b){var o=p("../utils"),l=p("./GenericWorker");function n(h){l.call(this,"DataWorker");var v=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,h.then(function(k){v.dataIsReady=!0,v.data=k,v.max=k&&k.length||0,v.type=o.getTypeOf(k),v.isPaused||v._tickAndRepeat()},function(k){v.error(k)})}o.inherits(n,l),n.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this.data=null},n.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},n.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},n.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var h=null,v=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":h=this.data.substring(this.index,v);break;case"uint8array":h=this.data.subarray(this.index,v);break;case"array":case"nodebuffer":h=this.data.slice(this.index,v)}return this.index=v,this.push({data:h,meta:{percent:this.max?this.index/this.max*100:0}})},D.exports=n},{"../utils":32,"./GenericWorker":28}],28:[function(p,D,b){function o(l){this.name=l||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}o.prototype={push:function(l){this.emit("data",l)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(l){this.emit("error",l)}return!0},error:function(l){return!this.isFinished&&(this.isPaused?this.generatedError=l:(this.isFinished=!0,this.emit("error",l),this.previous&&this.previous.error(l),this.cleanUp()),!0)},on:function(l,n){return this._listeners[l].push(n),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(l,n){if(this._listeners[l])for(var h=0;h<this._listeners[l].length;h++)this._listeners[l][h].call(this,n)},pipe:function(l){return l.registerPrevious(this)},registerPrevious:function(l){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=l.streamInfo,this.mergeStreamInfo(),this.previous=l;var n=this;return l.on("data",function(h){n.processChunk(h)}),l.on("end",function(){n.end()}),l.on("error",function(h){n.error(h)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var l=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),l=!0),this.previous&&this.previous.resume(),!l},flush:function(){},processChunk:function(l){this.push(l)},withStreamInfo:function(l,n){return this.extraStreamInfo[l]=n,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var l in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,l)&&(this.streamInfo[l]=this.extraStreamInfo[l])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var l="Worker "+this.name;return this.previous?this.previous+" -> "+l:l}},D.exports=o},{}],29:[function(p,D,b){var o=p("../utils"),l=p("./ConvertWorker"),n=p("./GenericWorker"),h=p("../base64"),v=p("../support"),k=p("../external"),_=null;if(v.nodestream)try{_=p("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(f,r){return new k.Promise(function(u,a){var d=[],w=f._internalType,z=f._outputType,S=f._mimeType;f.on("data",function(R,O){d.push(R),r&&r(O)}).on("error",function(R){d=[],a(R)}).on("end",function(){try{var R=(function(O,L,I){switch(O){case"blob":return o.newBlob(o.transformTo("arraybuffer",L),I);case"base64":return h.encode(L);default:return o.transformTo(O,L)}})(z,(function(O,L){var I,M=0,V=null,m=0;for(I=0;I<L.length;I++)m+=L[I].length;switch(O){case"string":return L.join("");case"array":return Array.prototype.concat.apply([],L);case"uint8array":for(V=new Uint8Array(m),I=0;I<L.length;I++)V.set(L[I],M),M+=L[I].length;return V;case"nodebuffer":return Buffer.concat(L);default:throw new Error("concat : unsupported type '"+O+"'")}})(w,d),S);u(R)}catch(O){a(O)}d=[]}).resume()})}function i(f,r,u){var a=r;switch(r){case"blob":case"arraybuffer":a="uint8array";break;case"base64":a="string"}try{this._internalType=a,this._outputType=r,this._mimeType=u,o.checkSupport(a),this._worker=f.pipe(new l(a)),f.lock()}catch(d){this._worker=new n("error"),this._worker.error(d)}}i.prototype={accumulate:function(f){return g(this,f)},on:function(f,r){var u=this;return f==="data"?this._worker.on(f,function(a){r.call(u,a.data,a.meta)}):this._worker.on(f,function(){o.delay(r,arguments,u)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(f){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new _(this,{objectMode:this._outputType!=="nodebuffer"},f)}},D.exports=i},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(p,D,b){if(b.base64=!0,b.array=!0,b.string=!0,b.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",b.nodebuffer=typeof Buffer<"u",b.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")b.blob=!1;else{var o=new ArrayBuffer(0);try{b.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var l=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);l.append(o),b.blob=l.getBlob("application/zip").size===0}catch{b.blob=!1}}}try{b.nodestream=!!p("readable-stream").Readable}catch{b.nodestream=!1}},{"readable-stream":16}],31:[function(p,D,b){for(var o=p("./utils"),l=p("./support"),n=p("./nodejsUtils"),h=p("./stream/GenericWorker"),v=new Array(256),k=0;k<256;k++)v[k]=252<=k?6:248<=k?5:240<=k?4:224<=k?3:192<=k?2:1;v[254]=v[254]=1;function _(){h.call(this,"utf-8 decode"),this.leftOver=null}function g(){h.call(this,"utf-8 encode")}b.utf8encode=function(i){return l.nodebuffer?n.newBufferFrom(i,"utf-8"):(function(f){var r,u,a,d,w,z=f.length,S=0;for(d=0;d<z;d++)(64512&(u=f.charCodeAt(d)))==55296&&d+1<z&&(64512&(a=f.charCodeAt(d+1)))==56320&&(u=65536+(u-55296<<10)+(a-56320),d++),S+=u<128?1:u<2048?2:u<65536?3:4;for(r=l.uint8array?new Uint8Array(S):new Array(S),d=w=0;w<S;d++)(64512&(u=f.charCodeAt(d)))==55296&&d+1<z&&(64512&(a=f.charCodeAt(d+1)))==56320&&(u=65536+(u-55296<<10)+(a-56320),d++),u<128?r[w++]=u:(u<2048?r[w++]=192|u>>>6:(u<65536?r[w++]=224|u>>>12:(r[w++]=240|u>>>18,r[w++]=128|u>>>12&63),r[w++]=128|u>>>6&63),r[w++]=128|63&u);return r})(i)},b.utf8decode=function(i){return l.nodebuffer?o.transformTo("nodebuffer",i).toString("utf-8"):(function(f){var r,u,a,d,w=f.length,z=new Array(2*w);for(r=u=0;r<w;)if((a=f[r++])<128)z[u++]=a;else if(4<(d=v[a]))z[u++]=65533,r+=d-1;else{for(a&=d===2?31:d===3?15:7;1<d&&r<w;)a=a<<6|63&f[r++],d--;1<d?z[u++]=65533:a<65536?z[u++]=a:(a-=65536,z[u++]=55296|a>>10&1023,z[u++]=56320|1023&a)}return z.length!==u&&(z.subarray?z=z.subarray(0,u):z.length=u),o.applyFromCharCode(z)})(i=o.transformTo(l.uint8array?"uint8array":"array",i))},o.inherits(_,h),_.prototype.processChunk=function(i){var f=o.transformTo(l.uint8array?"uint8array":"array",i.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var r=f;(f=new Uint8Array(r.length+this.leftOver.length)).set(this.leftOver,0),f.set(r,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var u=(function(d,w){var z;for((w=w||d.length)>d.length&&(w=d.length),z=w-1;0<=z&&(192&d[z])==128;)z--;return z<0||z===0?w:z+v[d[z]]>w?z:w})(f),a=f;u!==f.length&&(l.uint8array?(a=f.subarray(0,u),this.leftOver=f.subarray(u,f.length)):(a=f.slice(0,u),this.leftOver=f.slice(u,f.length))),this.push({data:b.utf8decode(a),meta:i.meta})},_.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:b.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},b.Utf8DecodeWorker=_,o.inherits(g,h),g.prototype.processChunk=function(i){this.push({data:b.utf8encode(i.data),meta:i.meta})},b.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(p,D,b){var o=p("./support"),l=p("./base64"),n=p("./nodejsUtils"),h=p("./external");function v(r){return r}function k(r,u){for(var a=0;a<r.length;++a)u[a]=255&r.charCodeAt(a);return u}p("setimmediate"),b.newBlob=function(r,u){b.checkSupport("blob");try{return new Blob([r],{type:u})}catch{try{var a=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return a.append(r),a.getBlob(u)}catch{throw new Error("Bug : can't construct the Blob.")}}};var _={stringifyByChunk:function(r,u,a){var d=[],w=0,z=r.length;if(z<=a)return String.fromCharCode.apply(null,r);for(;w<z;)u==="array"||u==="nodebuffer"?d.push(String.fromCharCode.apply(null,r.slice(w,Math.min(w+a,z)))):d.push(String.fromCharCode.apply(null,r.subarray(w,Math.min(w+a,z)))),w+=a;return d.join("")},stringifyByChar:function(r){for(var u="",a=0;a<r.length;a++)u+=String.fromCharCode(r[a]);return u},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,n.allocBuffer(1)).length===1}catch{return!1}})()}};function g(r){var u=65536,a=b.getTypeOf(r),d=!0;if(a==="uint8array"?d=_.applyCanBeUsed.uint8array:a==="nodebuffer"&&(d=_.applyCanBeUsed.nodebuffer),d)for(;1<u;)try{return _.stringifyByChunk(r,a,u)}catch{u=Math.floor(u/2)}return _.stringifyByChar(r)}function i(r,u){for(var a=0;a<r.length;a++)u[a]=r[a];return u}b.applyFromCharCode=g;var f={};f.string={string:v,array:function(r){return k(r,new Array(r.length))},arraybuffer:function(r){return f.string.uint8array(r).buffer},uint8array:function(r){return k(r,new Uint8Array(r.length))},nodebuffer:function(r){return k(r,n.allocBuffer(r.length))}},f.array={string:g,array:v,arraybuffer:function(r){return new Uint8Array(r).buffer},uint8array:function(r){return new Uint8Array(r)},nodebuffer:function(r){return n.newBufferFrom(r)}},f.arraybuffer={string:function(r){return g(new Uint8Array(r))},array:function(r){return i(new Uint8Array(r),new Array(r.byteLength))},arraybuffer:v,uint8array:function(r){return new Uint8Array(r)},nodebuffer:function(r){return n.newBufferFrom(new Uint8Array(r))}},f.uint8array={string:g,array:function(r){return i(r,new Array(r.length))},arraybuffer:function(r){return r.buffer},uint8array:v,nodebuffer:function(r){return n.newBufferFrom(r)}},f.nodebuffer={string:g,array:function(r){return i(r,new Array(r.length))},arraybuffer:function(r){return f.nodebuffer.uint8array(r).buffer},uint8array:function(r){return i(r,new Uint8Array(r.length))},nodebuffer:v},b.transformTo=function(r,u){if(u=u||"",!r)return u;b.checkSupport(r);var a=b.getTypeOf(u);return f[a][r](u)},b.resolve=function(r){for(var u=r.split("/"),a=[],d=0;d<u.length;d++){var w=u[d];w==="."||w===""&&d!==0&&d!==u.length-1||(w===".."?a.pop():a.push(w))}return a.join("/")},b.getTypeOf=function(r){return typeof r=="string"?"string":Object.prototype.toString.call(r)==="[object Array]"?"array":o.nodebuffer&&n.isBuffer(r)?"nodebuffer":o.uint8array&&r instanceof Uint8Array?"uint8array":o.arraybuffer&&r instanceof ArrayBuffer?"arraybuffer":void 0},b.checkSupport=function(r){if(!o[r.toLowerCase()])throw new Error(r+" is not supported by this platform")},b.MAX_VALUE_16BITS=65535,b.MAX_VALUE_32BITS=-1,b.pretty=function(r){var u,a,d="";for(a=0;a<(r||"").length;a++)d+="\\x"+((u=r.charCodeAt(a))<16?"0":"")+u.toString(16).toUpperCase();return d},b.delay=function(r,u,a){setImmediate(function(){r.apply(a||null,u||[])})},b.inherits=function(r,u){function a(){}a.prototype=u.prototype,r.prototype=new a},b.extend=function(){var r,u,a={};for(r=0;r<arguments.length;r++)for(u in arguments[r])Object.prototype.hasOwnProperty.call(arguments[r],u)&&a[u]===void 0&&(a[u]=arguments[r][u]);return a},b.prepareContent=function(r,u,a,d,w){return h.Promise.resolve(u).then(function(z){return o.blob&&(z instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(z))!==-1)&&typeof FileReader<"u"?new h.Promise(function(S,R){var O=new FileReader;O.onload=function(L){S(L.target.result)},O.onerror=function(L){R(L.target.error)},O.readAsArrayBuffer(z)}):z}).then(function(z){var S=b.getTypeOf(z);return S?(S==="arraybuffer"?z=b.transformTo("uint8array",z):S==="string"&&(w?z=l.decode(z):a&&d!==!0&&(z=(function(R){return k(R,o.uint8array?new Uint8Array(R.length):new Array(R.length))})(z))),z):h.Promise.reject(new Error("Can't read the data of '"+r+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(p,D,b){var o=p("./reader/readerFor"),l=p("./utils"),n=p("./signature"),h=p("./zipEntry"),v=p("./support");function k(_){this.files=[],this.loadOptions=_}k.prototype={checkSignature:function(_){if(!this.reader.readAndCheckSignature(_)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+l.pretty(g)+", expected "+l.pretty(_)+")")}},isSignature:function(_,g){var i=this.reader.index;this.reader.setIndex(_);var f=this.reader.readString(4)===g;return this.reader.setIndex(i),f},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var _=this.reader.readData(this.zipCommentLength),g=v.uint8array?"uint8array":"array",i=l.transformTo(g,_);this.zipComment=this.loadOptions.decodeFileName(i)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var _,g,i,f=this.zip64EndOfCentralSize-44;0<f;)_=this.reader.readInt(2),g=this.reader.readInt(4),i=this.reader.readData(g),this.zip64ExtensibleData[_]={id:_,length:g,value:i}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var _,g;for(_=0;_<this.files.length;_++)g=this.files[_],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(n.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var _;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(n.CENTRAL_FILE_HEADER);)(_=new h({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(_);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var _=this.reader.lastIndexOfSignature(n.CENTRAL_DIRECTORY_END);if(_<0)throw this.isSignature(0,n.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(_);var g=_;if(this.checkSignature(n.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===l.MAX_VALUE_16BITS||this.diskWithCentralDirStart===l.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===l.MAX_VALUE_16BITS||this.centralDirRecords===l.MAX_VALUE_16BITS||this.centralDirSize===l.MAX_VALUE_32BITS||this.centralDirOffset===l.MAX_VALUE_32BITS){if(this.zip64=!0,(_=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(_),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,n.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(n.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var f=g-i;if(0<f)this.isSignature(g,n.CENTRAL_FILE_HEADER)||(this.reader.zero=f);else if(f<0)throw new Error("Corrupted zip: missing "+Math.abs(f)+" bytes.")},prepareReader:function(_){this.reader=o(_)},load:function(_){this.prepareReader(_),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},D.exports=k},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(p,D,b){var o=p("./reader/readerFor"),l=p("./utils"),n=p("./compressedObject"),h=p("./crc32"),v=p("./utf8"),k=p("./compressions"),_=p("./support");function g(i,f){this.options=i,this.loadOptions=f}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(i){var f,r;if(i.skip(22),this.fileNameLength=i.readInt(2),r=i.readInt(2),this.fileName=i.readData(this.fileNameLength),i.skip(r),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((f=(function(u){for(var a in k)if(Object.prototype.hasOwnProperty.call(k,a)&&k[a].magic===u)return k[a];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+l.pretty(this.compressionMethod)+" unknown (inner file : "+l.transformTo("string",this.fileName)+")");this.decompressed=new n(this.compressedSize,this.uncompressedSize,this.crc32,f,i.readData(this.compressedSize))},readCentralPart:function(i){this.versionMadeBy=i.readInt(2),i.skip(2),this.bitFlag=i.readInt(2),this.compressionMethod=i.readString(2),this.date=i.readDate(),this.crc32=i.readInt(4),this.compressedSize=i.readInt(4),this.uncompressedSize=i.readInt(4);var f=i.readInt(2);if(this.extraFieldsLength=i.readInt(2),this.fileCommentLength=i.readInt(2),this.diskNumberStart=i.readInt(2),this.internalFileAttributes=i.readInt(2),this.externalFileAttributes=i.readInt(4),this.localHeaderOffset=i.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");i.skip(f),this.readExtraFields(i),this.parseZIP64ExtraField(i),this.fileComment=i.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var i=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),i==0&&(this.dosPermissions=63&this.externalFileAttributes),i==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var i=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=i.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=i.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=i.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=i.readInt(4))}},readExtraFields:function(i){var f,r,u,a=i.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});i.index+4<a;)f=i.readInt(2),r=i.readInt(2),u=i.readData(r),this.extraFields[f]={id:f,length:r,value:u};i.setIndex(a)},handleUTF8:function(){var i=_.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=v.utf8decode(this.fileName),this.fileCommentStr=v.utf8decode(this.fileComment);else{var f=this.findExtraFieldUnicodePath();if(f!==null)this.fileNameStr=f;else{var r=l.transformTo(i,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(r)}var u=this.findExtraFieldUnicodeComment();if(u!==null)this.fileCommentStr=u;else{var a=l.transformTo(i,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(a)}}},findExtraFieldUnicodePath:function(){var i=this.extraFields[28789];if(i){var f=o(i.value);return f.readInt(1)!==1||h(this.fileName)!==f.readInt(4)?null:v.utf8decode(f.readData(i.length-5))}return null},findExtraFieldUnicodeComment:function(){var i=this.extraFields[25461];if(i){var f=o(i.value);return f.readInt(1)!==1||h(this.fileComment)!==f.readInt(4)?null:v.utf8decode(f.readData(i.length-5))}return null}},D.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(p,D,b){function o(f,r,u){this.name=f,this.dir=u.dir,this.date=u.date,this.comment=u.comment,this.unixPermissions=u.unixPermissions,this.dosPermissions=u.dosPermissions,this._data=r,this._dataBinary=u.binary,this.options={compression:u.compression,compressionOptions:u.compressionOptions}}var l=p("./stream/StreamHelper"),n=p("./stream/DataWorker"),h=p("./utf8"),v=p("./compressedObject"),k=p("./stream/GenericWorker");o.prototype={internalStream:function(f){var r=null,u="string";try{if(!f)throw new Error("No output type specified.");var a=(u=f.toLowerCase())==="string"||u==="text";u!=="binarystring"&&u!=="text"||(u="string"),r=this._decompressWorker();var d=!this._dataBinary;d&&!a&&(r=r.pipe(new h.Utf8EncodeWorker)),!d&&a&&(r=r.pipe(new h.Utf8DecodeWorker))}catch(w){(r=new k("error")).error(w)}return new l(r,u,"")},async:function(f,r){return this.internalStream(f).accumulate(r)},nodeStream:function(f,r){return this.internalStream(f||"nodebuffer").toNodejsStream(r)},_compressWorker:function(f,r){if(this._data instanceof v&&this._data.compression.magic===f.magic)return this._data.getCompressedWorker();var u=this._decompressWorker();return this._dataBinary||(u=u.pipe(new h.Utf8EncodeWorker)),v.createWorkerFrom(u,f,r)},_decompressWorker:function(){return this._data instanceof v?this._data.getContentWorker():this._data instanceof k?this._data:new n(this._data)}};for(var _=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},i=0;i<_.length;i++)o.prototype[_[i]]=g;D.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(p,D,b){(function(o){var l,n,h=o.MutationObserver||o.WebKitMutationObserver;if(h){var v=0,k=new h(f),_=o.document.createTextNode("");k.observe(_,{characterData:!0}),l=function(){_.data=v=++v%2}}else if(o.setImmediate||o.MessageChannel===void 0)l="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var r=o.document.createElement("script");r.onreadystatechange=function(){f(),r.onreadystatechange=null,r.parentNode.removeChild(r),r=null},o.document.documentElement.appendChild(r)}:function(){setTimeout(f,0)};else{var g=new o.MessageChannel;g.port1.onmessage=f,l=function(){g.port2.postMessage(0)}}var i=[];function f(){var r,u;n=!0;for(var a=i.length;a;){for(u=i,i=[],r=-1;++r<a;)u[r]();a=i.length}n=!1}D.exports=function(r){i.push(r)!==1||n||l()}}).call(this,typeof zt<"u"?zt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(p,D,b){var o=p("immediate");function l(){}var n={},h=["REJECTED"],v=["FULFILLED"],k=["PENDING"];function _(a){if(typeof a!="function")throw new TypeError("resolver must be a function");this.state=k,this.queue=[],this.outcome=void 0,a!==l&&r(this,a)}function g(a,d,w){this.promise=a,typeof d=="function"&&(this.onFulfilled=d,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function i(a,d,w){o(function(){var z;try{z=d(w)}catch(S){return n.reject(a,S)}z===a?n.reject(a,new TypeError("Cannot resolve promise with itself")):n.resolve(a,z)})}function f(a){var d=a&&a.then;if(a&&(typeof a=="object"||typeof a=="function")&&typeof d=="function")return function(){d.apply(a,arguments)}}function r(a,d){var w=!1;function z(O){w||(w=!0,n.reject(a,O))}function S(O){w||(w=!0,n.resolve(a,O))}var R=u(function(){d(S,z)});R.status==="error"&&z(R.value)}function u(a,d){var w={};try{w.value=a(d),w.status="success"}catch(z){w.status="error",w.value=z}return w}(D.exports=_).prototype.finally=function(a){if(typeof a!="function")return this;var d=this.constructor;return this.then(function(w){return d.resolve(a()).then(function(){return w})},function(w){return d.resolve(a()).then(function(){throw w})})},_.prototype.catch=function(a){return this.then(null,a)},_.prototype.then=function(a,d){if(typeof a!="function"&&this.state===v||typeof d!="function"&&this.state===h)return this;var w=new this.constructor(l);return this.state!==k?i(w,this.state===v?a:d,this.outcome):this.queue.push(new g(w,a,d)),w},g.prototype.callFulfilled=function(a){n.resolve(this.promise,a)},g.prototype.otherCallFulfilled=function(a){i(this.promise,this.onFulfilled,a)},g.prototype.callRejected=function(a){n.reject(this.promise,a)},g.prototype.otherCallRejected=function(a){i(this.promise,this.onRejected,a)},n.resolve=function(a,d){var w=u(f,d);if(w.status==="error")return n.reject(a,w.value);var z=w.value;if(z)r(a,z);else{a.state=v,a.outcome=d;for(var S=-1,R=a.queue.length;++S<R;)a.queue[S].callFulfilled(d)}return a},n.reject=function(a,d){a.state=h,a.outcome=d;for(var w=-1,z=a.queue.length;++w<z;)a.queue[w].callRejected(d);return a},_.resolve=function(a){return a instanceof this?a:n.resolve(new this(l),a)},_.reject=function(a){var d=new this(l);return n.reject(d,a)},_.all=function(a){var d=this;if(Object.prototype.toString.call(a)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=a.length,z=!1;if(!w)return this.resolve([]);for(var S=new Array(w),R=0,O=-1,L=new this(l);++O<w;)I(a[O],O);return L;function I(M,V){d.resolve(M).then(function(m){S[V]=m,++R!==w||z||(z=!0,n.resolve(L,S))},function(m){z||(z=!0,n.reject(L,m))})}},_.race=function(a){var d=this;if(Object.prototype.toString.call(a)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=a.length,z=!1;if(!w)return this.resolve([]);for(var S=-1,R=new this(l);++S<w;)O=a[S],d.resolve(O).then(function(L){z||(z=!0,n.resolve(R,L))},function(L){z||(z=!0,n.reject(R,L))});var O;return R}},{immediate:36}],38:[function(p,D,b){var o={};(0,p("./lib/utils/common").assign)(o,p("./lib/deflate"),p("./lib/inflate"),p("./lib/zlib/constants")),D.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(p,D,b){var o=p("./zlib/deflate"),l=p("./utils/common"),n=p("./utils/strings"),h=p("./zlib/messages"),v=p("./zlib/zstream"),k=Object.prototype.toString,_=0,g=-1,i=0,f=8;function r(a){if(!(this instanceof r))return new r(a);this.options=l.assign({level:g,method:f,chunkSize:16384,windowBits:15,memLevel:8,strategy:i,to:""},a||{});var d=this.options;d.raw&&0<d.windowBits?d.windowBits=-d.windowBits:d.gzip&&0<d.windowBits&&d.windowBits<16&&(d.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new v,this.strm.avail_out=0;var w=o.deflateInit2(this.strm,d.level,d.method,d.windowBits,d.memLevel,d.strategy);if(w!==_)throw new Error(h[w]);if(d.header&&o.deflateSetHeader(this.strm,d.header),d.dictionary){var z;if(z=typeof d.dictionary=="string"?n.string2buf(d.dictionary):k.call(d.dictionary)==="[object ArrayBuffer]"?new Uint8Array(d.dictionary):d.dictionary,(w=o.deflateSetDictionary(this.strm,z))!==_)throw new Error(h[w]);this._dict_set=!0}}function u(a,d){var w=new r(d);if(w.push(a,!0),w.err)throw w.msg||h[w.err];return w.result}r.prototype.push=function(a,d){var w,z,S=this.strm,R=this.options.chunkSize;if(this.ended)return!1;z=d===~~d?d:d===!0?4:0,typeof a=="string"?S.input=n.string2buf(a):k.call(a)==="[object ArrayBuffer]"?S.input=new Uint8Array(a):S.input=a,S.next_in=0,S.avail_in=S.input.length;do{if(S.avail_out===0&&(S.output=new l.Buf8(R),S.next_out=0,S.avail_out=R),(w=o.deflate(S,z))!==1&&w!==_)return this.onEnd(w),!(this.ended=!0);S.avail_out!==0&&(S.avail_in!==0||z!==4&&z!==2)||(this.options.to==="string"?this.onData(n.buf2binstring(l.shrinkBuf(S.output,S.next_out))):this.onData(l.shrinkBuf(S.output,S.next_out)))}while((0<S.avail_in||S.avail_out===0)&&w!==1);return z===4?(w=o.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===_):z!==2||(this.onEnd(_),!(S.avail_out=0))},r.prototype.onData=function(a){this.chunks.push(a)},r.prototype.onEnd=function(a){a===_&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=l.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},b.Deflate=r,b.deflate=u,b.deflateRaw=function(a,d){return(d=d||{}).raw=!0,u(a,d)},b.gzip=function(a,d){return(d=d||{}).gzip=!0,u(a,d)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(p,D,b){var o=p("./zlib/inflate"),l=p("./utils/common"),n=p("./utils/strings"),h=p("./zlib/constants"),v=p("./zlib/messages"),k=p("./zlib/zstream"),_=p("./zlib/gzheader"),g=Object.prototype.toString;function i(r){if(!(this instanceof i))return new i(r);this.options=l.assign({chunkSize:16384,windowBits:0,to:""},r||{});var u=this.options;u.raw&&0<=u.windowBits&&u.windowBits<16&&(u.windowBits=-u.windowBits,u.windowBits===0&&(u.windowBits=-15)),!(0<=u.windowBits&&u.windowBits<16)||r&&r.windowBits||(u.windowBits+=32),15<u.windowBits&&u.windowBits<48&&(15&u.windowBits)==0&&(u.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var a=o.inflateInit2(this.strm,u.windowBits);if(a!==h.Z_OK)throw new Error(v[a]);this.header=new _,o.inflateGetHeader(this.strm,this.header)}function f(r,u){var a=new i(u);if(a.push(r,!0),a.err)throw a.msg||v[a.err];return a.result}i.prototype.push=function(r,u){var a,d,w,z,S,R,O=this.strm,L=this.options.chunkSize,I=this.options.dictionary,M=!1;if(this.ended)return!1;d=u===~~u?u:u===!0?h.Z_FINISH:h.Z_NO_FLUSH,typeof r=="string"?O.input=n.binstring2buf(r):g.call(r)==="[object ArrayBuffer]"?O.input=new Uint8Array(r):O.input=r,O.next_in=0,O.avail_in=O.input.length;do{if(O.avail_out===0&&(O.output=new l.Buf8(L),O.next_out=0,O.avail_out=L),(a=o.inflate(O,h.Z_NO_FLUSH))===h.Z_NEED_DICT&&I&&(R=typeof I=="string"?n.string2buf(I):g.call(I)==="[object ArrayBuffer]"?new Uint8Array(I):I,a=o.inflateSetDictionary(this.strm,R)),a===h.Z_BUF_ERROR&&M===!0&&(a=h.Z_OK,M=!1),a!==h.Z_STREAM_END&&a!==h.Z_OK)return this.onEnd(a),!(this.ended=!0);O.next_out&&(O.avail_out!==0&&a!==h.Z_STREAM_END&&(O.avail_in!==0||d!==h.Z_FINISH&&d!==h.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=n.utf8border(O.output,O.next_out),z=O.next_out-w,S=n.buf2string(O.output,w),O.next_out=z,O.avail_out=L-z,z&&l.arraySet(O.output,O.output,w,z,0),this.onData(S)):this.onData(l.shrinkBuf(O.output,O.next_out)))),O.avail_in===0&&O.avail_out===0&&(M=!0)}while((0<O.avail_in||O.avail_out===0)&&a!==h.Z_STREAM_END);return a===h.Z_STREAM_END&&(d=h.Z_FINISH),d===h.Z_FINISH?(a=o.inflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===h.Z_OK):d!==h.Z_SYNC_FLUSH||(this.onEnd(h.Z_OK),!(O.avail_out=0))},i.prototype.onData=function(r){this.chunks.push(r)},i.prototype.onEnd=function(r){r===h.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=l.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg},b.Inflate=i,b.inflate=f,b.inflateRaw=function(r,u){return(u=u||{}).raw=!0,f(r,u)},b.ungzip=f},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(p,D,b){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";b.assign=function(h){for(var v=Array.prototype.slice.call(arguments,1);v.length;){var k=v.shift();if(k){if(typeof k!="object")throw new TypeError(k+"must be non-object");for(var _ in k)k.hasOwnProperty(_)&&(h[_]=k[_])}}return h},b.shrinkBuf=function(h,v){return h.length===v?h:h.subarray?h.subarray(0,v):(h.length=v,h)};var l={arraySet:function(h,v,k,_,g){if(v.subarray&&h.subarray)h.set(v.subarray(k,k+_),g);else for(var i=0;i<_;i++)h[g+i]=v[k+i]},flattenChunks:function(h){var v,k,_,g,i,f;for(v=_=0,k=h.length;v<k;v++)_+=h[v].length;for(f=new Uint8Array(_),v=g=0,k=h.length;v<k;v++)i=h[v],f.set(i,g),g+=i.length;return f}},n={arraySet:function(h,v,k,_,g){for(var i=0;i<_;i++)h[g+i]=v[k+i]},flattenChunks:function(h){return[].concat.apply([],h)}};b.setTyped=function(h){h?(b.Buf8=Uint8Array,b.Buf16=Uint16Array,b.Buf32=Int32Array,b.assign(b,l)):(b.Buf8=Array,b.Buf16=Array,b.Buf32=Array,b.assign(b,n))},b.setTyped(o)},{}],42:[function(p,D,b){var o=p("./common"),l=!0,n=!0;try{String.fromCharCode.apply(null,[0])}catch{l=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{n=!1}for(var h=new o.Buf8(256),v=0;v<256;v++)h[v]=252<=v?6:248<=v?5:240<=v?4:224<=v?3:192<=v?2:1;function k(_,g){if(g<65537&&(_.subarray&&n||!_.subarray&&l))return String.fromCharCode.apply(null,o.shrinkBuf(_,g));for(var i="",f=0;f<g;f++)i+=String.fromCharCode(_[f]);return i}h[254]=h[254]=1,b.string2buf=function(_){var g,i,f,r,u,a=_.length,d=0;for(r=0;r<a;r++)(64512&(i=_.charCodeAt(r)))==55296&&r+1<a&&(64512&(f=_.charCodeAt(r+1)))==56320&&(i=65536+(i-55296<<10)+(f-56320),r++),d+=i<128?1:i<2048?2:i<65536?3:4;for(g=new o.Buf8(d),r=u=0;u<d;r++)(64512&(i=_.charCodeAt(r)))==55296&&r+1<a&&(64512&(f=_.charCodeAt(r+1)))==56320&&(i=65536+(i-55296<<10)+(f-56320),r++),i<128?g[u++]=i:(i<2048?g[u++]=192|i>>>6:(i<65536?g[u++]=224|i>>>12:(g[u++]=240|i>>>18,g[u++]=128|i>>>12&63),g[u++]=128|i>>>6&63),g[u++]=128|63&i);return g},b.buf2binstring=function(_){return k(_,_.length)},b.binstring2buf=function(_){for(var g=new o.Buf8(_.length),i=0,f=g.length;i<f;i++)g[i]=_.charCodeAt(i);return g},b.buf2string=function(_,g){var i,f,r,u,a=g||_.length,d=new Array(2*a);for(i=f=0;i<a;)if((r=_[i++])<128)d[f++]=r;else if(4<(u=h[r]))d[f++]=65533,i+=u-1;else{for(r&=u===2?31:u===3?15:7;1<u&&i<a;)r=r<<6|63&_[i++],u--;1<u?d[f++]=65533:r<65536?d[f++]=r:(r-=65536,d[f++]=55296|r>>10&1023,d[f++]=56320|1023&r)}return k(d,f)},b.utf8border=function(_,g){var i;for((g=g||_.length)>_.length&&(g=_.length),i=g-1;0<=i&&(192&_[i])==128;)i--;return i<0||i===0?g:i+h[_[i]]>g?i:g}},{"./common":41}],43:[function(p,D,b){D.exports=function(o,l,n,h){for(var v=65535&o|0,k=o>>>16&65535|0,_=0;n!==0;){for(n-=_=2e3<n?2e3:n;k=k+(v=v+l[h++]|0)|0,--_;);v%=65521,k%=65521}return v|k<<16|0}},{}],44:[function(p,D,b){D.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(p,D,b){var o=(function(){for(var l,n=[],h=0;h<256;h++){l=h;for(var v=0;v<8;v++)l=1&l?3988292384^l>>>1:l>>>1;n[h]=l}return n})();D.exports=function(l,n,h,v){var k=o,_=v+h;l^=-1;for(var g=v;g<_;g++)l=l>>>8^k[255&(l^n[g])];return-1^l}},{}],46:[function(p,D,b){var o,l=p("../utils/common"),n=p("./trees"),h=p("./adler32"),v=p("./crc32"),k=p("./messages"),_=0,g=4,i=0,f=-2,r=-1,u=4,a=2,d=8,w=9,z=286,S=30,R=19,O=2*z+1,L=15,I=3,M=258,V=M+I+1,m=42,T=113,e=1,N=2,J=3,U=4;function Q(t,B){return t.msg=k[B],B}function Z(t){return(t<<1)-(4<t?9:0)}function $(t){for(var B=t.length;0<=--B;)t[B]=0}function C(t){var B=t.state,A=B.pending;A>t.avail_out&&(A=t.avail_out),A!==0&&(l.arraySet(t.output,B.pending_buf,B.pending_out,A,t.next_out),t.next_out+=A,B.pending_out+=A,t.total_out+=A,t.avail_out-=A,B.pending-=A,B.pending===0&&(B.pending_out=0))}function y(t,B){n._tr_flush_block(t,0<=t.block_start?t.block_start:-1,t.strstart-t.block_start,B),t.block_start=t.strstart,C(t.strm)}function G(t,B){t.pending_buf[t.pending++]=B}function K(t,B){t.pending_buf[t.pending++]=B>>>8&255,t.pending_buf[t.pending++]=255&B}function F(t,B){var A,c,s=t.max_chain_length,x=t.strstart,j=t.prev_length,P=t.nice_match,E=t.strstart>t.w_size-V?t.strstart-(t.w_size-V):0,W=t.window,Y=t.w_mask,H=t.prev,X=t.strstart+M,at=W[x+j-1],nt=W[x+j];t.prev_length>=t.good_match&&(s>>=2),P>t.lookahead&&(P=t.lookahead);do if(W[(A=B)+j]===nt&&W[A+j-1]===at&&W[A]===W[x]&&W[++A]===W[x+1]){x+=2,A++;do;while(W[++x]===W[++A]&&W[++x]===W[++A]&&W[++x]===W[++A]&&W[++x]===W[++A]&&W[++x]===W[++A]&&W[++x]===W[++A]&&W[++x]===W[++A]&&W[++x]===W[++A]&&x<X);if(c=M-(X-x),x=X-M,j<c){if(t.match_start=B,P<=(j=c))break;at=W[x+j-1],nt=W[x+j]}}while((B=H[B&Y])>E&&--s!=0);return j<=t.lookahead?j:t.lookahead}function st(t){var B,A,c,s,x,j,P,E,W,Y,H=t.w_size;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=H+(H-V)){for(l.arraySet(t.window,t.window,H,H,0),t.match_start-=H,t.strstart-=H,t.block_start-=H,B=A=t.hash_size;c=t.head[--B],t.head[B]=H<=c?c-H:0,--A;);for(B=A=H;c=t.prev[--B],t.prev[B]=H<=c?c-H:0,--A;);s+=H}if(t.strm.avail_in===0)break;if(j=t.strm,P=t.window,E=t.strstart+t.lookahead,W=s,Y=void 0,Y=j.avail_in,W<Y&&(Y=W),A=Y===0?0:(j.avail_in-=Y,l.arraySet(P,j.input,j.next_in,Y,E),j.state.wrap===1?j.adler=h(j.adler,P,Y,E):j.state.wrap===2&&(j.adler=v(j.adler,P,Y,E)),j.next_in+=Y,j.total_in+=Y,Y),t.lookahead+=A,t.lookahead+t.insert>=I)for(x=t.strstart-t.insert,t.ins_h=t.window[x],t.ins_h=(t.ins_h<<t.hash_shift^t.window[x+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[x+I-1])&t.hash_mask,t.prev[x&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=x,x++,t.insert--,!(t.lookahead+t.insert<I)););}while(t.lookahead<V&&t.strm.avail_in!==0)}function ut(t,B){for(var A,c;;){if(t.lookahead<V){if(st(t),t.lookahead<V&&B===_)return e;if(t.lookahead===0)break}if(A=0,t.lookahead>=I&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),A!==0&&t.strstart-A<=t.w_size-V&&(t.match_length=F(t,A)),t.match_length>=I)if(c=n._tr_tally(t,t.strstart-t.match_start,t.match_length-I),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=I){for(t.match_length--;t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart,--t.match_length!=0;);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else c=n._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(c&&(y(t,!1),t.strm.avail_out===0))return e}return t.insert=t.strstart<I-1?t.strstart:I-1,B===g?(y(t,!0),t.strm.avail_out===0?J:U):t.last_lit&&(y(t,!1),t.strm.avail_out===0)?e:N}function rt(t,B){for(var A,c,s;;){if(t.lookahead<V){if(st(t),t.lookahead<V&&B===_)return e;if(t.lookahead===0)break}if(A=0,t.lookahead>=I&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=I-1,A!==0&&t.prev_length<t.max_lazy_match&&t.strstart-A<=t.w_size-V&&(t.match_length=F(t,A),t.match_length<=5&&(t.strategy===1||t.match_length===I&&4096<t.strstart-t.match_start)&&(t.match_length=I-1)),t.prev_length>=I&&t.match_length<=t.prev_length){for(s=t.strstart+t.lookahead-I,c=n._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-I),t.lookahead-=t.prev_length-1,t.prev_length-=2;++t.strstart<=s&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+I-1])&t.hash_mask,A=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),--t.prev_length!=0;);if(t.match_available=0,t.match_length=I-1,t.strstart++,c&&(y(t,!1),t.strm.avail_out===0))return e}else if(t.match_available){if((c=n._tr_tally(t,0,t.window[t.strstart-1]))&&y(t,!1),t.strstart++,t.lookahead--,t.strm.avail_out===0)return e}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(c=n._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<I-1?t.strstart:I-1,B===g?(y(t,!0),t.strm.avail_out===0?J:U):t.last_lit&&(y(t,!1),t.strm.avail_out===0)?e:N}function tt(t,B,A,c,s){this.good_length=t,this.max_lazy=B,this.nice_length=A,this.max_chain=c,this.func=s}function ct(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=d,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new l.Buf16(2*O),this.dyn_dtree=new l.Buf16(2*(2*S+1)),this.bl_tree=new l.Buf16(2*(2*R+1)),$(this.dyn_ltree),$(this.dyn_dtree),$(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new l.Buf16(L+1),this.heap=new l.Buf16(2*z+1),$(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new l.Buf16(2*z+1),$(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function ot(t){var B;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=a,(B=t.state).pending=0,B.pending_out=0,B.wrap<0&&(B.wrap=-B.wrap),B.status=B.wrap?m:T,t.adler=B.wrap===2?0:1,B.last_flush=_,n._tr_init(B),i):Q(t,f)}function pt(t){var B=ot(t);return B===i&&(function(A){A.window_size=2*A.w_size,$(A.head),A.max_lazy_match=o[A.level].max_lazy,A.good_match=o[A.level].good_length,A.nice_match=o[A.level].nice_length,A.max_chain_length=o[A.level].max_chain,A.strstart=0,A.block_start=0,A.lookahead=0,A.insert=0,A.match_length=A.prev_length=I-1,A.match_available=0,A.ins_h=0})(t.state),B}function dt(t,B,A,c,s,x){if(!t)return f;var j=1;if(B===r&&(B=6),c<0?(j=0,c=-c):15<c&&(j=2,c-=16),s<1||w<s||A!==d||c<8||15<c||B<0||9<B||x<0||u<x)return Q(t,f);c===8&&(c=9);var P=new ct;return(t.state=P).strm=t,P.wrap=j,P.gzhead=null,P.w_bits=c,P.w_size=1<<P.w_bits,P.w_mask=P.w_size-1,P.hash_bits=s+7,P.hash_size=1<<P.hash_bits,P.hash_mask=P.hash_size-1,P.hash_shift=~~((P.hash_bits+I-1)/I),P.window=new l.Buf8(2*P.w_size),P.head=new l.Buf16(P.hash_size),P.prev=new l.Buf16(P.w_size),P.lit_bufsize=1<<s+6,P.pending_buf_size=4*P.lit_bufsize,P.pending_buf=new l.Buf8(P.pending_buf_size),P.d_buf=1*P.lit_bufsize,P.l_buf=3*P.lit_bufsize,P.level=B,P.strategy=x,P.method=A,pt(t)}o=[new tt(0,0,0,0,function(t,B){var A=65535;for(A>t.pending_buf_size-5&&(A=t.pending_buf_size-5);;){if(t.lookahead<=1){if(st(t),t.lookahead===0&&B===_)return e;if(t.lookahead===0)break}t.strstart+=t.lookahead,t.lookahead=0;var c=t.block_start+A;if((t.strstart===0||t.strstart>=c)&&(t.lookahead=t.strstart-c,t.strstart=c,y(t,!1),t.strm.avail_out===0)||t.strstart-t.block_start>=t.w_size-V&&(y(t,!1),t.strm.avail_out===0))return e}return t.insert=0,B===g?(y(t,!0),t.strm.avail_out===0?J:U):(t.strstart>t.block_start&&(y(t,!1),t.strm.avail_out),e)}),new tt(4,4,8,4,ut),new tt(4,5,16,8,ut),new tt(4,6,32,32,ut),new tt(4,4,16,16,rt),new tt(8,16,32,32,rt),new tt(8,16,128,128,rt),new tt(8,32,128,256,rt),new tt(32,128,258,1024,rt),new tt(32,258,258,4096,rt)],b.deflateInit=function(t,B){return dt(t,B,d,15,8,0)},b.deflateInit2=dt,b.deflateReset=pt,b.deflateResetKeep=ot,b.deflateSetHeader=function(t,B){return t&&t.state?t.state.wrap!==2?f:(t.state.gzhead=B,i):f},b.deflate=function(t,B){var A,c,s,x;if(!t||!t.state||5<B||B<0)return t?Q(t,f):f;if(c=t.state,!t.output||!t.input&&t.avail_in!==0||c.status===666&&B!==g)return Q(t,t.avail_out===0?-5:f);if(c.strm=t,A=c.last_flush,c.last_flush=B,c.status===m)if(c.wrap===2)t.adler=0,G(c,31),G(c,139),G(c,8),c.gzhead?(G(c,(c.gzhead.text?1:0)+(c.gzhead.hcrc?2:0)+(c.gzhead.extra?4:0)+(c.gzhead.name?8:0)+(c.gzhead.comment?16:0)),G(c,255&c.gzhead.time),G(c,c.gzhead.time>>8&255),G(c,c.gzhead.time>>16&255),G(c,c.gzhead.time>>24&255),G(c,c.level===9?2:2<=c.strategy||c.level<2?4:0),G(c,255&c.gzhead.os),c.gzhead.extra&&c.gzhead.extra.length&&(G(c,255&c.gzhead.extra.length),G(c,c.gzhead.extra.length>>8&255)),c.gzhead.hcrc&&(t.adler=v(t.adler,c.pending_buf,c.pending,0)),c.gzindex=0,c.status=69):(G(c,0),G(c,0),G(c,0),G(c,0),G(c,0),G(c,c.level===9?2:2<=c.strategy||c.level<2?4:0),G(c,3),c.status=T);else{var j=d+(c.w_bits-8<<4)<<8;j|=(2<=c.strategy||c.level<2?0:c.level<6?1:c.level===6?2:3)<<6,c.strstart!==0&&(j|=32),j+=31-j%31,c.status=T,K(c,j),c.strstart!==0&&(K(c,t.adler>>>16),K(c,65535&t.adler)),t.adler=1}if(c.status===69)if(c.gzhead.extra){for(s=c.pending;c.gzindex<(65535&c.gzhead.extra.length)&&(c.pending!==c.pending_buf_size||(c.gzhead.hcrc&&c.pending>s&&(t.adler=v(t.adler,c.pending_buf,c.pending-s,s)),C(t),s=c.pending,c.pending!==c.pending_buf_size));)G(c,255&c.gzhead.extra[c.gzindex]),c.gzindex++;c.gzhead.hcrc&&c.pending>s&&(t.adler=v(t.adler,c.pending_buf,c.pending-s,s)),c.gzindex===c.gzhead.extra.length&&(c.gzindex=0,c.status=73)}else c.status=73;if(c.status===73)if(c.gzhead.name){s=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>s&&(t.adler=v(t.adler,c.pending_buf,c.pending-s,s)),C(t),s=c.pending,c.pending===c.pending_buf_size)){x=1;break}x=c.gzindex<c.gzhead.name.length?255&c.gzhead.name.charCodeAt(c.gzindex++):0,G(c,x)}while(x!==0);c.gzhead.hcrc&&c.pending>s&&(t.adler=v(t.adler,c.pending_buf,c.pending-s,s)),x===0&&(c.gzindex=0,c.status=91)}else c.status=91;if(c.status===91)if(c.gzhead.comment){s=c.pending;do{if(c.pending===c.pending_buf_size&&(c.gzhead.hcrc&&c.pending>s&&(t.adler=v(t.adler,c.pending_buf,c.pending-s,s)),C(t),s=c.pending,c.pending===c.pending_buf_size)){x=1;break}x=c.gzindex<c.gzhead.comment.length?255&c.gzhead.comment.charCodeAt(c.gzindex++):0,G(c,x)}while(x!==0);c.gzhead.hcrc&&c.pending>s&&(t.adler=v(t.adler,c.pending_buf,c.pending-s,s)),x===0&&(c.status=103)}else c.status=103;if(c.status===103&&(c.gzhead.hcrc?(c.pending+2>c.pending_buf_size&&C(t),c.pending+2<=c.pending_buf_size&&(G(c,255&t.adler),G(c,t.adler>>8&255),t.adler=0,c.status=T)):c.status=T),c.pending!==0){if(C(t),t.avail_out===0)return c.last_flush=-1,i}else if(t.avail_in===0&&Z(B)<=Z(A)&&B!==g)return Q(t,-5);if(c.status===666&&t.avail_in!==0)return Q(t,-5);if(t.avail_in!==0||c.lookahead!==0||B!==_&&c.status!==666){var P=c.strategy===2?(function(E,W){for(var Y;;){if(E.lookahead===0&&(st(E),E.lookahead===0)){if(W===_)return e;break}if(E.match_length=0,Y=n._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++,Y&&(y(E,!1),E.strm.avail_out===0))return e}return E.insert=0,W===g?(y(E,!0),E.strm.avail_out===0?J:U):E.last_lit&&(y(E,!1),E.strm.avail_out===0)?e:N})(c,B):c.strategy===3?(function(E,W){for(var Y,H,X,at,nt=E.window;;){if(E.lookahead<=M){if(st(E),E.lookahead<=M&&W===_)return e;if(E.lookahead===0)break}if(E.match_length=0,E.lookahead>=I&&0<E.strstart&&(H=nt[X=E.strstart-1])===nt[++X]&&H===nt[++X]&&H===nt[++X]){at=E.strstart+M;do;while(H===nt[++X]&&H===nt[++X]&&H===nt[++X]&&H===nt[++X]&&H===nt[++X]&&H===nt[++X]&&H===nt[++X]&&H===nt[++X]&&X<at);E.match_length=M-(at-X),E.match_length>E.lookahead&&(E.match_length=E.lookahead)}if(E.match_length>=I?(Y=n._tr_tally(E,1,E.match_length-I),E.lookahead-=E.match_length,E.strstart+=E.match_length,E.match_length=0):(Y=n._tr_tally(E,0,E.window[E.strstart]),E.lookahead--,E.strstart++),Y&&(y(E,!1),E.strm.avail_out===0))return e}return E.insert=0,W===g?(y(E,!0),E.strm.avail_out===0?J:U):E.last_lit&&(y(E,!1),E.strm.avail_out===0)?e:N})(c,B):o[c.level].func(c,B);if(P!==J&&P!==U||(c.status=666),P===e||P===J)return t.avail_out===0&&(c.last_flush=-1),i;if(P===N&&(B===1?n._tr_align(c):B!==5&&(n._tr_stored_block(c,0,0,!1),B===3&&($(c.head),c.lookahead===0&&(c.strstart=0,c.block_start=0,c.insert=0))),C(t),t.avail_out===0))return c.last_flush=-1,i}return B!==g?i:c.wrap<=0?1:(c.wrap===2?(G(c,255&t.adler),G(c,t.adler>>8&255),G(c,t.adler>>16&255),G(c,t.adler>>24&255),G(c,255&t.total_in),G(c,t.total_in>>8&255),G(c,t.total_in>>16&255),G(c,t.total_in>>24&255)):(K(c,t.adler>>>16),K(c,65535&t.adler)),C(t),0<c.wrap&&(c.wrap=-c.wrap),c.pending!==0?i:1)},b.deflateEnd=function(t){var B;return t&&t.state?(B=t.state.status)!==m&&B!==69&&B!==73&&B!==91&&B!==103&&B!==T&&B!==666?Q(t,f):(t.state=null,B===T?Q(t,-3):i):f},b.deflateSetDictionary=function(t,B){var A,c,s,x,j,P,E,W,Y=B.length;if(!t||!t.state||(x=(A=t.state).wrap)===2||x===1&&A.status!==m||A.lookahead)return f;for(x===1&&(t.adler=h(t.adler,B,Y,0)),A.wrap=0,Y>=A.w_size&&(x===0&&($(A.head),A.strstart=0,A.block_start=0,A.insert=0),W=new l.Buf8(A.w_size),l.arraySet(W,B,Y-A.w_size,A.w_size,0),B=W,Y=A.w_size),j=t.avail_in,P=t.next_in,E=t.input,t.avail_in=Y,t.next_in=0,t.input=B,st(A);A.lookahead>=I;){for(c=A.strstart,s=A.lookahead-(I-1);A.ins_h=(A.ins_h<<A.hash_shift^A.window[c+I-1])&A.hash_mask,A.prev[c&A.w_mask]=A.head[A.ins_h],A.head[A.ins_h]=c,c++,--s;);A.strstart=c,A.lookahead=I-1,st(A)}return A.strstart+=A.lookahead,A.block_start=A.strstart,A.insert=A.lookahead,A.lookahead=0,A.match_length=A.prev_length=I-1,A.match_available=0,t.next_in=P,t.input=E,t.avail_in=j,A.wrap=x,i},b.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(p,D,b){D.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(p,D,b){D.exports=function(o,l){var n,h,v,k,_,g,i,f,r,u,a,d,w,z,S,R,O,L,I,M,V,m,T,e,N;n=o.state,h=o.next_in,e=o.input,v=h+(o.avail_in-5),k=o.next_out,N=o.output,_=k-(l-o.avail_out),g=k+(o.avail_out-257),i=n.dmax,f=n.wsize,r=n.whave,u=n.wnext,a=n.window,d=n.hold,w=n.bits,z=n.lencode,S=n.distcode,R=(1<<n.lenbits)-1,O=(1<<n.distbits)-1;t:do{w<15&&(d+=e[h++]<<w,w+=8,d+=e[h++]<<w,w+=8),L=z[d&R];e:for(;;){if(d>>>=I=L>>>24,w-=I,(I=L>>>16&255)===0)N[k++]=65535&L;else{if(!(16&I)){if((64&I)==0){L=z[(65535&L)+(d&(1<<I)-1)];continue e}if(32&I){n.mode=12;break t}o.msg="invalid literal/length code",n.mode=30;break t}M=65535&L,(I&=15)&&(w<I&&(d+=e[h++]<<w,w+=8),M+=d&(1<<I)-1,d>>>=I,w-=I),w<15&&(d+=e[h++]<<w,w+=8,d+=e[h++]<<w,w+=8),L=S[d&O];r:for(;;){if(d>>>=I=L>>>24,w-=I,!(16&(I=L>>>16&255))){if((64&I)==0){L=S[(65535&L)+(d&(1<<I)-1)];continue r}o.msg="invalid distance code",n.mode=30;break t}if(V=65535&L,w<(I&=15)&&(d+=e[h++]<<w,(w+=8)<I&&(d+=e[h++]<<w,w+=8)),i<(V+=d&(1<<I)-1)){o.msg="invalid distance too far back",n.mode=30;break t}if(d>>>=I,w-=I,(I=k-_)<V){if(r<(I=V-I)&&n.sane){o.msg="invalid distance too far back",n.mode=30;break t}if(T=a,(m=0)===u){if(m+=f-I,I<M){for(M-=I;N[k++]=a[m++],--I;);m=k-V,T=N}}else if(u<I){if(m+=f+u-I,(I-=u)<M){for(M-=I;N[k++]=a[m++],--I;);if(m=0,u<M){for(M-=I=u;N[k++]=a[m++],--I;);m=k-V,T=N}}}else if(m+=u-I,I<M){for(M-=I;N[k++]=a[m++],--I;);m=k-V,T=N}for(;2<M;)N[k++]=T[m++],N[k++]=T[m++],N[k++]=T[m++],M-=3;M&&(N[k++]=T[m++],1<M&&(N[k++]=T[m++]))}else{for(m=k-V;N[k++]=N[m++],N[k++]=N[m++],N[k++]=N[m++],2<(M-=3););M&&(N[k++]=N[m++],1<M&&(N[k++]=N[m++]))}break}}break}}while(h<v&&k<g);h-=M=w>>3,d&=(1<<(w-=M<<3))-1,o.next_in=h,o.next_out=k,o.avail_in=h<v?v-h+5:5-(h-v),o.avail_out=k<g?g-k+257:257-(k-g),n.hold=d,n.bits=w}},{}],49:[function(p,D,b){var o=p("../utils/common"),l=p("./adler32"),n=p("./crc32"),h=p("./inffast"),v=p("./inftrees"),k=1,_=2,g=0,i=-2,f=1,r=852,u=592;function a(m){return(m>>>24&255)+(m>>>8&65280)+((65280&m)<<8)+((255&m)<<24)}function d(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(m){var T;return m&&m.state?(T=m.state,m.total_in=m.total_out=T.total=0,m.msg="",T.wrap&&(m.adler=1&T.wrap),T.mode=f,T.last=0,T.havedict=0,T.dmax=32768,T.head=null,T.hold=0,T.bits=0,T.lencode=T.lendyn=new o.Buf32(r),T.distcode=T.distdyn=new o.Buf32(u),T.sane=1,T.back=-1,g):i}function z(m){var T;return m&&m.state?((T=m.state).wsize=0,T.whave=0,T.wnext=0,w(m)):i}function S(m,T){var e,N;return m&&m.state?(N=m.state,T<0?(e=0,T=-T):(e=1+(T>>4),T<48&&(T&=15)),T&&(T<8||15<T)?i:(N.window!==null&&N.wbits!==T&&(N.window=null),N.wrap=e,N.wbits=T,z(m))):i}function R(m,T){var e,N;return m?(N=new d,(m.state=N).window=null,(e=S(m,T))!==g&&(m.state=null),e):i}var O,L,I=!0;function M(m){if(I){var T;for(O=new o.Buf32(512),L=new o.Buf32(32),T=0;T<144;)m.lens[T++]=8;for(;T<256;)m.lens[T++]=9;for(;T<280;)m.lens[T++]=7;for(;T<288;)m.lens[T++]=8;for(v(k,m.lens,0,288,O,0,m.work,{bits:9}),T=0;T<32;)m.lens[T++]=5;v(_,m.lens,0,32,L,0,m.work,{bits:5}),I=!1}m.lencode=O,m.lenbits=9,m.distcode=L,m.distbits=5}function V(m,T,e,N){var J,U=m.state;return U.window===null&&(U.wsize=1<<U.wbits,U.wnext=0,U.whave=0,U.window=new o.Buf8(U.wsize)),N>=U.wsize?(o.arraySet(U.window,T,e-U.wsize,U.wsize,0),U.wnext=0,U.whave=U.wsize):(N<(J=U.wsize-U.wnext)&&(J=N),o.arraySet(U.window,T,e-N,J,U.wnext),(N-=J)?(o.arraySet(U.window,T,e-N,N,0),U.wnext=N,U.whave=U.wsize):(U.wnext+=J,U.wnext===U.wsize&&(U.wnext=0),U.whave<U.wsize&&(U.whave+=J))),0}b.inflateReset=z,b.inflateReset2=S,b.inflateResetKeep=w,b.inflateInit=function(m){return R(m,15)},b.inflateInit2=R,b.inflate=function(m,T){var e,N,J,U,Q,Z,$,C,y,G,K,F,st,ut,rt,tt,ct,ot,pt,dt,t,B,A,c,s=0,x=new o.Buf8(4),j=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!m||!m.state||!m.output||!m.input&&m.avail_in!==0)return i;(e=m.state).mode===12&&(e.mode=13),Q=m.next_out,J=m.output,$=m.avail_out,U=m.next_in,N=m.input,Z=m.avail_in,C=e.hold,y=e.bits,G=Z,K=$,B=g;t:for(;;)switch(e.mode){case f:if(e.wrap===0){e.mode=13;break}for(;y<16;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(2&e.wrap&&C===35615){x[e.check=0]=255&C,x[1]=C>>>8&255,e.check=n(e.check,x,2,0),y=C=0,e.mode=2;break}if(e.flags=0,e.head&&(e.head.done=!1),!(1&e.wrap)||(((255&C)<<8)+(C>>8))%31){m.msg="incorrect header check",e.mode=30;break}if((15&C)!=8){m.msg="unknown compression method",e.mode=30;break}if(y-=4,t=8+(15&(C>>>=4)),e.wbits===0)e.wbits=t;else if(t>e.wbits){m.msg="invalid window size",e.mode=30;break}e.dmax=1<<t,m.adler=e.check=1,e.mode=512&C?10:12,y=C=0;break;case 2:for(;y<16;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(e.flags=C,(255&e.flags)!=8){m.msg="unknown compression method",e.mode=30;break}if(57344&e.flags){m.msg="unknown header flags set",e.mode=30;break}e.head&&(e.head.text=C>>8&1),512&e.flags&&(x[0]=255&C,x[1]=C>>>8&255,e.check=n(e.check,x,2,0)),y=C=0,e.mode=3;case 3:for(;y<32;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}e.head&&(e.head.time=C),512&e.flags&&(x[0]=255&C,x[1]=C>>>8&255,x[2]=C>>>16&255,x[3]=C>>>24&255,e.check=n(e.check,x,4,0)),y=C=0,e.mode=4;case 4:for(;y<16;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}e.head&&(e.head.xflags=255&C,e.head.os=C>>8),512&e.flags&&(x[0]=255&C,x[1]=C>>>8&255,e.check=n(e.check,x,2,0)),y=C=0,e.mode=5;case 5:if(1024&e.flags){for(;y<16;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}e.length=C,e.head&&(e.head.extra_len=C),512&e.flags&&(x[0]=255&C,x[1]=C>>>8&255,e.check=n(e.check,x,2,0)),y=C=0}else e.head&&(e.head.extra=null);e.mode=6;case 6:if(1024&e.flags&&(Z<(F=e.length)&&(F=Z),F&&(e.head&&(t=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Array(e.head.extra_len)),o.arraySet(e.head.extra,N,U,F,t)),512&e.flags&&(e.check=n(e.check,N,F,U)),Z-=F,U+=F,e.length-=F),e.length))break t;e.length=0,e.mode=7;case 7:if(2048&e.flags){if(Z===0)break t;for(F=0;t=N[U+F++],e.head&&t&&e.length<65536&&(e.head.name+=String.fromCharCode(t)),t&&F<Z;);if(512&e.flags&&(e.check=n(e.check,N,F,U)),Z-=F,U+=F,t)break t}else e.head&&(e.head.name=null);e.length=0,e.mode=8;case 8:if(4096&e.flags){if(Z===0)break t;for(F=0;t=N[U+F++],e.head&&t&&e.length<65536&&(e.head.comment+=String.fromCharCode(t)),t&&F<Z;);if(512&e.flags&&(e.check=n(e.check,N,F,U)),Z-=F,U+=F,t)break t}else e.head&&(e.head.comment=null);e.mode=9;case 9:if(512&e.flags){for(;y<16;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(C!==(65535&e.check)){m.msg="header crc mismatch",e.mode=30;break}y=C=0}e.head&&(e.head.hcrc=e.flags>>9&1,e.head.done=!0),m.adler=e.check=0,e.mode=12;break;case 10:for(;y<32;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}m.adler=e.check=a(C),y=C=0,e.mode=11;case 11:if(e.havedict===0)return m.next_out=Q,m.avail_out=$,m.next_in=U,m.avail_in=Z,e.hold=C,e.bits=y,2;m.adler=e.check=1,e.mode=12;case 12:if(T===5||T===6)break t;case 13:if(e.last){C>>>=7&y,y-=7&y,e.mode=27;break}for(;y<3;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}switch(e.last=1&C,y-=1,3&(C>>>=1)){case 0:e.mode=14;break;case 1:if(M(e),e.mode=20,T!==6)break;C>>>=2,y-=2;break t;case 2:e.mode=17;break;case 3:m.msg="invalid block type",e.mode=30}C>>>=2,y-=2;break;case 14:for(C>>>=7&y,y-=7&y;y<32;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if((65535&C)!=(C>>>16^65535)){m.msg="invalid stored block lengths",e.mode=30;break}if(e.length=65535&C,y=C=0,e.mode=15,T===6)break t;case 15:e.mode=16;case 16:if(F=e.length){if(Z<F&&(F=Z),$<F&&(F=$),F===0)break t;o.arraySet(J,N,U,F,Q),Z-=F,U+=F,$-=F,Q+=F,e.length-=F;break}e.mode=12;break;case 17:for(;y<14;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(e.nlen=257+(31&C),C>>>=5,y-=5,e.ndist=1+(31&C),C>>>=5,y-=5,e.ncode=4+(15&C),C>>>=4,y-=4,286<e.nlen||30<e.ndist){m.msg="too many length or distance symbols",e.mode=30;break}e.have=0,e.mode=18;case 18:for(;e.have<e.ncode;){for(;y<3;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}e.lens[j[e.have++]]=7&C,C>>>=3,y-=3}for(;e.have<19;)e.lens[j[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},B=v(0,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,B){m.msg="invalid code lengths set",e.mode=30;break}e.have=0,e.mode=19;case 19:for(;e.have<e.nlen+e.ndist;){for(;tt=(s=e.lencode[C&(1<<e.lenbits)-1])>>>16&255,ct=65535&s,!((rt=s>>>24)<=y);){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(ct<16)C>>>=rt,y-=rt,e.lens[e.have++]=ct;else{if(ct===16){for(c=rt+2;y<c;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(C>>>=rt,y-=rt,e.have===0){m.msg="invalid bit length repeat",e.mode=30;break}t=e.lens[e.have-1],F=3+(3&C),C>>>=2,y-=2}else if(ct===17){for(c=rt+3;y<c;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}y-=rt,t=0,F=3+(7&(C>>>=rt)),C>>>=3,y-=3}else{for(c=rt+7;y<c;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}y-=rt,t=0,F=11+(127&(C>>>=rt)),C>>>=7,y-=7}if(e.have+F>e.nlen+e.ndist){m.msg="invalid bit length repeat",e.mode=30;break}for(;F--;)e.lens[e.have++]=t}}if(e.mode===30)break;if(e.lens[256]===0){m.msg="invalid code -- missing end-of-block",e.mode=30;break}if(e.lenbits=9,A={bits:e.lenbits},B=v(k,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,B){m.msg="invalid literal/lengths set",e.mode=30;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},B=v(_,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,B){m.msg="invalid distances set",e.mode=30;break}if(e.mode=20,T===6)break t;case 20:e.mode=21;case 21:if(6<=Z&&258<=$){m.next_out=Q,m.avail_out=$,m.next_in=U,m.avail_in=Z,e.hold=C,e.bits=y,h(m,K),Q=m.next_out,J=m.output,$=m.avail_out,U=m.next_in,N=m.input,Z=m.avail_in,C=e.hold,y=e.bits,e.mode===12&&(e.back=-1);break}for(e.back=0;tt=(s=e.lencode[C&(1<<e.lenbits)-1])>>>16&255,ct=65535&s,!((rt=s>>>24)<=y);){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(tt&&(240&tt)==0){for(ot=rt,pt=tt,dt=ct;tt=(s=e.lencode[dt+((C&(1<<ot+pt)-1)>>ot)])>>>16&255,ct=65535&s,!(ot+(rt=s>>>24)<=y);){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}C>>>=ot,y-=ot,e.back+=ot}if(C>>>=rt,y-=rt,e.back+=rt,e.length=ct,tt===0){e.mode=26;break}if(32&tt){e.back=-1,e.mode=12;break}if(64&tt){m.msg="invalid literal/length code",e.mode=30;break}e.extra=15&tt,e.mode=22;case 22:if(e.extra){for(c=e.extra;y<c;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}e.length+=C&(1<<e.extra)-1,C>>>=e.extra,y-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=23;case 23:for(;tt=(s=e.distcode[C&(1<<e.distbits)-1])>>>16&255,ct=65535&s,!((rt=s>>>24)<=y);){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if((240&tt)==0){for(ot=rt,pt=tt,dt=ct;tt=(s=e.distcode[dt+((C&(1<<ot+pt)-1)>>ot)])>>>16&255,ct=65535&s,!(ot+(rt=s>>>24)<=y);){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}C>>>=ot,y-=ot,e.back+=ot}if(C>>>=rt,y-=rt,e.back+=rt,64&tt){m.msg="invalid distance code",e.mode=30;break}e.offset=ct,e.extra=15&tt,e.mode=24;case 24:if(e.extra){for(c=e.extra;y<c;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}e.offset+=C&(1<<e.extra)-1,C>>>=e.extra,y-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){m.msg="invalid distance too far back",e.mode=30;break}e.mode=25;case 25:if($===0)break t;if(F=K-$,e.offset>F){if((F=e.offset-F)>e.whave&&e.sane){m.msg="invalid distance too far back",e.mode=30;break}st=F>e.wnext?(F-=e.wnext,e.wsize-F):e.wnext-F,F>e.length&&(F=e.length),ut=e.window}else ut=J,st=Q-e.offset,F=e.length;for($<F&&(F=$),$-=F,e.length-=F;J[Q++]=ut[st++],--F;);e.length===0&&(e.mode=21);break;case 26:if($===0)break t;J[Q++]=e.length,$--,e.mode=21;break;case 27:if(e.wrap){for(;y<32;){if(Z===0)break t;Z--,C|=N[U++]<<y,y+=8}if(K-=$,m.total_out+=K,e.total+=K,K&&(m.adler=e.check=e.flags?n(e.check,J,K,Q-K):l(e.check,J,K,Q-K)),K=$,(e.flags?C:a(C))!==e.check){m.msg="incorrect data check",e.mode=30;break}y=C=0}e.mode=28;case 28:if(e.wrap&&e.flags){for(;y<32;){if(Z===0)break t;Z--,C+=N[U++]<<y,y+=8}if(C!==(4294967295&e.total)){m.msg="incorrect length check",e.mode=30;break}y=C=0}e.mode=29;case 29:B=1;break t;case 30:B=-3;break t;case 31:return-4;default:return i}return m.next_out=Q,m.avail_out=$,m.next_in=U,m.avail_in=Z,e.hold=C,e.bits=y,(e.wsize||K!==m.avail_out&&e.mode<30&&(e.mode<27||T!==4))&&V(m,m.output,m.next_out,K-m.avail_out)?(e.mode=31,-4):(G-=m.avail_in,K-=m.avail_out,m.total_in+=G,m.total_out+=K,e.total+=K,e.wrap&&K&&(m.adler=e.check=e.flags?n(e.check,J,K,m.next_out-K):l(e.check,J,K,m.next_out-K)),m.data_type=e.bits+(e.last?64:0)+(e.mode===12?128:0)+(e.mode===20||e.mode===15?256:0),(G==0&&K===0||T===4)&&B===g&&(B=-5),B)},b.inflateEnd=function(m){if(!m||!m.state)return i;var T=m.state;return T.window&&(T.window=null),m.state=null,g},b.inflateGetHeader=function(m,T){var e;return m&&m.state?(2&(e=m.state).wrap)==0?i:((e.head=T).done=!1,g):i},b.inflateSetDictionary=function(m,T){var e,N=T.length;return m&&m.state?(e=m.state).wrap!==0&&e.mode!==11?i:e.mode===11&&l(1,T,N,0)!==e.check?-3:V(m,T,N,N)?(e.mode=31,-4):(e.havedict=1,g):i},b.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(p,D,b){var o=p("../utils/common"),l=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],n=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],h=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],v=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];D.exports=function(k,_,g,i,f,r,u,a){var d,w,z,S,R,O,L,I,M,V=a.bits,m=0,T=0,e=0,N=0,J=0,U=0,Q=0,Z=0,$=0,C=0,y=null,G=0,K=new o.Buf16(16),F=new o.Buf16(16),st=null,ut=0;for(m=0;m<=15;m++)K[m]=0;for(T=0;T<i;T++)K[_[g+T]]++;for(J=V,N=15;1<=N&&K[N]===0;N--);if(N<J&&(J=N),N===0)return f[r++]=20971520,f[r++]=20971520,a.bits=1,0;for(e=1;e<N&&K[e]===0;e++);for(J<e&&(J=e),m=Z=1;m<=15;m++)if(Z<<=1,(Z-=K[m])<0)return-1;if(0<Z&&(k===0||N!==1))return-1;for(F[1]=0,m=1;m<15;m++)F[m+1]=F[m]+K[m];for(T=0;T<i;T++)_[g+T]!==0&&(u[F[_[g+T]]++]=T);if(O=k===0?(y=st=u,19):k===1?(y=l,G-=257,st=n,ut-=257,256):(y=h,st=v,-1),m=e,R=r,Q=T=C=0,z=-1,S=($=1<<(U=J))-1,k===1&&852<$||k===2&&592<$)return 1;for(;;){for(L=m-Q,M=u[T]<O?(I=0,u[T]):u[T]>O?(I=st[ut+u[T]],y[G+u[T]]):(I=96,0),d=1<<m-Q,e=w=1<<U;f[R+(C>>Q)+(w-=d)]=L<<24|I<<16|M|0,w!==0;);for(d=1<<m-1;C&d;)d>>=1;if(d!==0?(C&=d-1,C+=d):C=0,T++,--K[m]==0){if(m===N)break;m=_[g+u[T]]}if(J<m&&(C&S)!==z){for(Q===0&&(Q=J),R+=e,Z=1<<(U=m-Q);U+Q<N&&!((Z-=K[U+Q])<=0);)U++,Z<<=1;if($+=1<<U,k===1&&852<$||k===2&&592<$)return 1;f[z=C&S]=J<<24|U<<16|R-r|0}}return C!==0&&(f[R+C]=m-Q<<24|64<<16|0),a.bits=J,0}},{"../utils/common":41}],51:[function(p,D,b){D.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(p,D,b){var o=p("../utils/common"),l=0,n=1;function h(s){for(var x=s.length;0<=--x;)s[x]=0}var v=0,k=29,_=256,g=_+1+k,i=30,f=19,r=2*g+1,u=15,a=16,d=7,w=256,z=16,S=17,R=18,O=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],L=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],V=new Array(2*(g+2));h(V);var m=new Array(2*i);h(m);var T=new Array(512);h(T);var e=new Array(256);h(e);var N=new Array(k);h(N);var J,U,Q,Z=new Array(i);function $(s,x,j,P,E){this.static_tree=s,this.extra_bits=x,this.extra_base=j,this.elems=P,this.max_length=E,this.has_stree=s&&s.length}function C(s,x){this.dyn_tree=s,this.max_code=0,this.stat_desc=x}function y(s){return s<256?T[s]:T[256+(s>>>7)]}function G(s,x){s.pending_buf[s.pending++]=255&x,s.pending_buf[s.pending++]=x>>>8&255}function K(s,x,j){s.bi_valid>a-j?(s.bi_buf|=x<<s.bi_valid&65535,G(s,s.bi_buf),s.bi_buf=x>>a-s.bi_valid,s.bi_valid+=j-a):(s.bi_buf|=x<<s.bi_valid&65535,s.bi_valid+=j)}function F(s,x,j){K(s,j[2*x],j[2*x+1])}function st(s,x){for(var j=0;j|=1&s,s>>>=1,j<<=1,0<--x;);return j>>>1}function ut(s,x,j){var P,E,W=new Array(u+1),Y=0;for(P=1;P<=u;P++)W[P]=Y=Y+j[P-1]<<1;for(E=0;E<=x;E++){var H=s[2*E+1];H!==0&&(s[2*E]=st(W[H]++,H))}}function rt(s){var x;for(x=0;x<g;x++)s.dyn_ltree[2*x]=0;for(x=0;x<i;x++)s.dyn_dtree[2*x]=0;for(x=0;x<f;x++)s.bl_tree[2*x]=0;s.dyn_ltree[2*w]=1,s.opt_len=s.static_len=0,s.last_lit=s.matches=0}function tt(s){8<s.bi_valid?G(s,s.bi_buf):0<s.bi_valid&&(s.pending_buf[s.pending++]=s.bi_buf),s.bi_buf=0,s.bi_valid=0}function ct(s,x,j,P){var E=2*x,W=2*j;return s[E]<s[W]||s[E]===s[W]&&P[x]<=P[j]}function ot(s,x,j){for(var P=s.heap[j],E=j<<1;E<=s.heap_len&&(E<s.heap_len&&ct(x,s.heap[E+1],s.heap[E],s.depth)&&E++,!ct(x,P,s.heap[E],s.depth));)s.heap[j]=s.heap[E],j=E,E<<=1;s.heap[j]=P}function pt(s,x,j){var P,E,W,Y,H=0;if(s.last_lit!==0)for(;P=s.pending_buf[s.d_buf+2*H]<<8|s.pending_buf[s.d_buf+2*H+1],E=s.pending_buf[s.l_buf+H],H++,P===0?F(s,E,x):(F(s,(W=e[E])+_+1,x),(Y=O[W])!==0&&K(s,E-=N[W],Y),F(s,W=y(--P),j),(Y=L[W])!==0&&K(s,P-=Z[W],Y)),H<s.last_lit;);F(s,w,x)}function dt(s,x){var j,P,E,W=x.dyn_tree,Y=x.stat_desc.static_tree,H=x.stat_desc.has_stree,X=x.stat_desc.elems,at=-1;for(s.heap_len=0,s.heap_max=r,j=0;j<X;j++)W[2*j]!==0?(s.heap[++s.heap_len]=at=j,s.depth[j]=0):W[2*j+1]=0;for(;s.heap_len<2;)W[2*(E=s.heap[++s.heap_len]=at<2?++at:0)]=1,s.depth[E]=0,s.opt_len--,H&&(s.static_len-=Y[2*E+1]);for(x.max_code=at,j=s.heap_len>>1;1<=j;j--)ot(s,W,j);for(E=X;j=s.heap[1],s.heap[1]=s.heap[s.heap_len--],ot(s,W,1),P=s.heap[1],s.heap[--s.heap_max]=j,s.heap[--s.heap_max]=P,W[2*E]=W[2*j]+W[2*P],s.depth[E]=(s.depth[j]>=s.depth[P]?s.depth[j]:s.depth[P])+1,W[2*j+1]=W[2*P+1]=E,s.heap[1]=E++,ot(s,W,1),2<=s.heap_len;);s.heap[--s.heap_max]=s.heap[1],(function(nt,ft){var yt,mt,bt,lt,xt,At,gt=ft.dyn_tree,Tt=ft.max_code,Wt=ft.stat_desc.static_tree,Ht=ft.stat_desc.has_stree,Kt=ft.stat_desc.extra_bits,Bt=ft.stat_desc.extra_base,wt=ft.stat_desc.max_length,St=0;for(lt=0;lt<=u;lt++)nt.bl_count[lt]=0;for(gt[2*nt.heap[nt.heap_max]+1]=0,yt=nt.heap_max+1;yt<r;yt++)wt<(lt=gt[2*gt[2*(mt=nt.heap[yt])+1]+1]+1)&&(lt=wt,St++),gt[2*mt+1]=lt,Tt<mt||(nt.bl_count[lt]++,xt=0,Bt<=mt&&(xt=Kt[mt-Bt]),At=gt[2*mt],nt.opt_len+=At*(lt+xt),Ht&&(nt.static_len+=At*(Wt[2*mt+1]+xt)));if(St!==0){do{for(lt=wt-1;nt.bl_count[lt]===0;)lt--;nt.bl_count[lt]--,nt.bl_count[lt+1]+=2,nt.bl_count[wt]--,St-=2}while(0<St);for(lt=wt;lt!==0;lt--)for(mt=nt.bl_count[lt];mt!==0;)Tt<(bt=nt.heap[--yt])||(gt[2*bt+1]!==lt&&(nt.opt_len+=(lt-gt[2*bt+1])*gt[2*bt],gt[2*bt+1]=lt),mt--)}})(s,x),ut(W,at,s.bl_count)}function t(s,x,j){var P,E,W=-1,Y=x[1],H=0,X=7,at=4;for(Y===0&&(X=138,at=3),x[2*(j+1)+1]=65535,P=0;P<=j;P++)E=Y,Y=x[2*(P+1)+1],++H<X&&E===Y||(H<at?s.bl_tree[2*E]+=H:E!==0?(E!==W&&s.bl_tree[2*E]++,s.bl_tree[2*z]++):H<=10?s.bl_tree[2*S]++:s.bl_tree[2*R]++,W=E,at=(H=0)===Y?(X=138,3):E===Y?(X=6,3):(X=7,4))}function B(s,x,j){var P,E,W=-1,Y=x[1],H=0,X=7,at=4;for(Y===0&&(X=138,at=3),P=0;P<=j;P++)if(E=Y,Y=x[2*(P+1)+1],!(++H<X&&E===Y)){if(H<at)for(;F(s,E,s.bl_tree),--H!=0;);else E!==0?(E!==W&&(F(s,E,s.bl_tree),H--),F(s,z,s.bl_tree),K(s,H-3,2)):H<=10?(F(s,S,s.bl_tree),K(s,H-3,3)):(F(s,R,s.bl_tree),K(s,H-11,7));W=E,at=(H=0)===Y?(X=138,3):E===Y?(X=6,3):(X=7,4)}}h(Z);var A=!1;function c(s,x,j,P){K(s,(v<<1)+(P?1:0),3),(function(E,W,Y,H){tt(E),G(E,Y),G(E,~Y),o.arraySet(E.pending_buf,E.window,W,Y,E.pending),E.pending+=Y})(s,x,j)}b._tr_init=function(s){A||((function(){var x,j,P,E,W,Y=new Array(u+1);for(E=P=0;E<k-1;E++)for(N[E]=P,x=0;x<1<<O[E];x++)e[P++]=E;for(e[P-1]=E,E=W=0;E<16;E++)for(Z[E]=W,x=0;x<1<<L[E];x++)T[W++]=E;for(W>>=7;E<i;E++)for(Z[E]=W<<7,x=0;x<1<<L[E]-7;x++)T[256+W++]=E;for(j=0;j<=u;j++)Y[j]=0;for(x=0;x<=143;)V[2*x+1]=8,x++,Y[8]++;for(;x<=255;)V[2*x+1]=9,x++,Y[9]++;for(;x<=279;)V[2*x+1]=7,x++,Y[7]++;for(;x<=287;)V[2*x+1]=8,x++,Y[8]++;for(ut(V,g+1,Y),x=0;x<i;x++)m[2*x+1]=5,m[2*x]=st(x,5);J=new $(V,O,_+1,g,u),U=new $(m,L,0,i,u),Q=new $(new Array(0),I,0,f,d)})(),A=!0),s.l_desc=new C(s.dyn_ltree,J),s.d_desc=new C(s.dyn_dtree,U),s.bl_desc=new C(s.bl_tree,Q),s.bi_buf=0,s.bi_valid=0,rt(s)},b._tr_stored_block=c,b._tr_flush_block=function(s,x,j,P){var E,W,Y=0;0<s.level?(s.strm.data_type===2&&(s.strm.data_type=(function(H){var X,at=4093624447;for(X=0;X<=31;X++,at>>>=1)if(1&at&&H.dyn_ltree[2*X]!==0)return l;if(H.dyn_ltree[18]!==0||H.dyn_ltree[20]!==0||H.dyn_ltree[26]!==0)return n;for(X=32;X<_;X++)if(H.dyn_ltree[2*X]!==0)return n;return l})(s)),dt(s,s.l_desc),dt(s,s.d_desc),Y=(function(H){var X;for(t(H,H.dyn_ltree,H.l_desc.max_code),t(H,H.dyn_dtree,H.d_desc.max_code),dt(H,H.bl_desc),X=f-1;3<=X&&H.bl_tree[2*M[X]+1]===0;X--);return H.opt_len+=3*(X+1)+5+5+4,X})(s),E=s.opt_len+3+7>>>3,(W=s.static_len+3+7>>>3)<=E&&(E=W)):E=W=j+5,j+4<=E&&x!==-1?c(s,x,j,P):s.strategy===4||W===E?(K(s,2+(P?1:0),3),pt(s,V,m)):(K(s,4+(P?1:0),3),(function(H,X,at,nt){var ft;for(K(H,X-257,5),K(H,at-1,5),K(H,nt-4,4),ft=0;ft<nt;ft++)K(H,H.bl_tree[2*M[ft]+1],3);B(H,H.dyn_ltree,X-1),B(H,H.dyn_dtree,at-1)})(s,s.l_desc.max_code+1,s.d_desc.max_code+1,Y+1),pt(s,s.dyn_ltree,s.dyn_dtree)),rt(s),P&&tt(s)},b._tr_tally=function(s,x,j){return s.pending_buf[s.d_buf+2*s.last_lit]=x>>>8&255,s.pending_buf[s.d_buf+2*s.last_lit+1]=255&x,s.pending_buf[s.l_buf+s.last_lit]=255&j,s.last_lit++,x===0?s.dyn_ltree[2*j]++:(s.matches++,x--,s.dyn_ltree[2*(e[j]+_+1)]++,s.dyn_dtree[2*y(x)]++),s.last_lit===s.lit_bufsize-1},b._tr_align=function(s){K(s,2,3),F(s,w,V),(function(x){x.bi_valid===16?(G(x,x.bi_buf),x.bi_buf=0,x.bi_valid=0):8<=x.bi_valid&&(x.pending_buf[x.pending++]=255&x.bi_buf,x.bi_buf>>=8,x.bi_valid-=8)})(s)}},{"../utils/common":41}],53:[function(p,D,b){D.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(p,D,b){(function(o){(function(l,n){if(!l.setImmediate){var h,v,k,_,g=1,i={},f=!1,r=l.document,u=Object.getPrototypeOf&&Object.getPrototypeOf(l);u=u&&u.setTimeout?u:l,h={}.toString.call(l.process)==="[object process]"?function(z){process.nextTick(function(){d(z)})}:(function(){if(l.postMessage&&!l.importScripts){var z=!0,S=l.onmessage;return l.onmessage=function(){z=!1},l.postMessage("","*"),l.onmessage=S,z}})()?(_="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",w,!1):l.attachEvent("onmessage",w),function(z){l.postMessage(_+z,"*")}):l.MessageChannel?((k=new MessageChannel).port1.onmessage=function(z){d(z.data)},function(z){k.port2.postMessage(z)}):r&&"onreadystatechange"in r.createElement("script")?(v=r.documentElement,function(z){var S=r.createElement("script");S.onreadystatechange=function(){d(z),S.onreadystatechange=null,v.removeChild(S),S=null},v.appendChild(S)}):function(z){setTimeout(d,0,z)},u.setImmediate=function(z){typeof z!="function"&&(z=new Function(""+z));for(var S=new Array(arguments.length-1),R=0;R<S.length;R++)S[R]=arguments[R+1];var O={callback:z,args:S};return i[g]=O,h(g),g++},u.clearImmediate=a}function a(z){delete i[z]}function d(z){if(f)setTimeout(d,0,z);else{var S=i[z];if(S){f=!0;try{(function(R){var O=R.callback,L=R.args;switch(L.length){case 0:O();break;case 1:O(L[0]);break;case 2:O(L[0],L[1]);break;case 3:O(L[0],L[1],L[2]);break;default:O.apply(n,L)}})(S)}finally{a(z),f=!1}}}}function w(z){z.source===l&&typeof z.data=="string"&&z.data.indexOf(_)===0&&d(+z.data.slice(_.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof zt<"u"?zt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Rt)),Rt.exports}var de=fe();const ke=Gt(de),pe=it=>{const ht=it.trim();if(!ht)return null;try{const p=new URL(ht);return p.protocol==="http:"||p.protocol==="https:"?p.toString():null}catch{return null}},me=it=>({id:it?.key??"",key:it?.key??"",name:it?.name??"",value:it?.value??"",valueType:it?.valueType??"text",persistedKey:it?.key}),_e=it=>{if(Array.isArray(it))return it;const ht=it?.keys;return Array.isArray(ht)?ht:[]},Ot=(it=[])=>it.map(me),Mt=(it,ht)=>{const p=[],D=new Set(ht);for(const b of it){const o=b.key.trim();if(!o)continue;const l=b.value.trim(),n=!!b.persistedKey&&(b.valueType==="number"||b.valueType==="date"||b.valueType==="select"||b.valueType==="url");if(!l&&n){D.add(b.persistedKey);continue}!l&&b.valueType!=="text"&&b.valueType!=="boolean"||p.push({key:o,name:b.name.trim()||o,value:b.valueType==="boolean"?l||"false":l,valueType:b.valueType})}return{set:p.sort((b,o)=>b.key.localeCompare(o.key)),deleteKeys:Array.from(D).sort()}},vt=(it,ht=[])=>JSON.stringify(Mt(it,ht)),xe=et.forwardRef(function({noteId:ht,properties:p=[],expectedUpdatedAt:D,editSessionId:b,disabled:o,saveProperties:l=$t,onPendingChange:n,onSaved:h},v){const k=se(),_=Jt(),[g,i]=et.useState(()=>Ot(p)),[f,r]=et.useState([]),[u,a]=et.useState("idle"),d=et.useRef(g),w=et.useRef(f),z=et.useRef(D),S=et.useRef(vt(g)),R=et.useRef(null),O=et.useRef(!1),L=et.useRef(null),I=et.useRef(!1),M=et.useRef(0),V=Yt({queryKey:Nt.notes.propertyKeys({limit:50}),queryFn:async()=>{const y=await oe({limit:50});if(y.type==="error")throw y;return y.notePropertyKeys.keys}});et.useEffect(()=>{const y=Ot(p);i(y),r([]),S.current=vt(y),a("idle")},[p]),et.useEffect(()=>{d.current=g},[g]),et.useEffect(()=>{w.current=f},[f]),et.useEffect(()=>{z.current=D},[D]);const m=_e(V.data),T=m.filter(y=>!g.some(G=>G.key===y.key)),e=m.length>0,N=vt(g,f)!==S.current,J=et.useCallback(async({ignoreDisabled:y=!1,expectedUpdatedAt:G}={})=>{if(R.current&&(clearTimeout(R.current),R.current=null),L.current){I.current=!0;const tt=await L.current;return tt==="error"?tt:J({ignoreDisabled:y})}const K=vt(d.current,w.current);if(!y&&o||K===S.current)return"idle";const F=Mt(d.current,w.current);if(F.set.length===0&&F.deleteKeys.length===0)return"idle";O.current=!0,I.current=!1,a("saving");const st=M.current,ut=(async()=>{try{const tt=await l({id:ht,set:F.set,deleteKeys:F.deleteKeys,editSessionId:b,expectedUpdatedAt:G??z.current});return!tt||st!==M.current?(a("idle"),"idle"):tt.type==="error"?(a("error"),k(tt.errors[0]?.message??"Failed to save properties."),"error"):(z.current=tt.updateNoteProperties.updatedAt,S.current=vt(Ot(tt.updateNoteProperties.properties??[])),await h(tt.updateNoteProperties),_.invalidateQueries({queryKey:Nt.notes.propertyKeysAll(),exact:!1}),a("saved"),"saved")}catch{return a("error"),k("Failed to save properties."),"error"}finally{O.current=!1}})();L.current=ut;const rt=await ut;if(L.current===ut&&(L.current=null),I.current){I.current=!1;const tt=await J({ignoreDisabled:y});return tt==="idle"?rt:tt}return rt},[o,b,ht,h,_,l,k]);et.useImperativeHandle(v,()=>({flushPendingSave:({expectedUpdatedAt:y}={})=>J({ignoreDisabled:!0,expectedUpdatedAt:y}),invalidateInFlightSave:()=>{M.current+=1,R.current&&(clearTimeout(R.current),R.current=null)},discardPendingChanges:()=>{M.current+=1,I.current=!1,S.current=vt(d.current,w.current),a("idle"),R.current&&(clearTimeout(R.current),R.current=null)}}),[J]),et.useEffect(()=>{n?.(N||u==="saving")},[u,N,n]),et.useEffect(()=>{if(R.current&&clearTimeout(R.current),!(o||vt(g,f)===S.current))return R.current=setTimeout(()=>{J()},500),()=>{R.current&&clearTimeout(R.current)}},[f,o,g,J]);const U=y=>{i(G=>[...G,{id:y.key,key:y.key,name:y.name,value:"",valueType:y.valueType,persistedKey:void 0}]),r(G=>G.filter(K=>K!==y.key))},Q=(y,G)=>{i(K=>K.map(F=>F.id===y?{...F,...G}:F))},Z=y=>{y.persistedKey&&r(G=>[...new Set([...G,y.persistedKey])]),i(G=>G.filter(K=>K.id!==y.id))},$=vt(g,f)!==S.current,C=o||!$&&u==="idle"?null:u==="saving"?"Saving...":u==="error"?"Save failed":$?"Waiting...":"Saved";return q.jsxs(ce,{title:"Properties",icon:q.jsx(Vt,{className:"h-3.5 w-3.5"}),ariaLabel:"Note properties",action:q.jsxs(q.Fragment,{children:[C&&q.jsx(_t,{as:"span",variant:"micro",tone:u==="error"?"error":"tertiary",className:"px-1",children:C}),e&&q.jsx(kt,{asChild:!0,size:"sm",variant:"ghost",children:q.jsxs(Ft,{to:Pt,search:{page:1},children:[q.jsx(qt,{className:"h-3 w-3"}),"Manage"]})})]}),children:[g.length===0?q.jsx(_t,{as:"p",variant:"label",tone:"tertiary",className:"px-1 py-2",children:"No properties yet."}):q.jsx("div",{className:"divide-y divide-border-subtle",children:g.map(y=>{const G=`note-property-${y.id}-label`,K=y.valueType==="url"?pe(y.value):null;return q.jsxs("div",{className:"group grid gap-2 py-2 sm:grid-cols-[minmax(0,180px)_minmax(0,1fr)_auto] sm:items-center",children:[q.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-1",children:[q.jsx(_t,{id:G,as:"span",variant:"label",tone:"secondary",className:"truncate",children:y.name}),q.jsx(_t,{as:"span",variant:"micro",tone:"tertiary",className:"hidden truncate font-mono sm:inline",children:y.key})]}),y.valueType==="boolean"?q.jsxs(Dt,{size:"sm",variant:"ghost",value:y.value||"false",disabled:o,"aria-labelledby":G,onValueChange:F=>Q(y.id,{value:F}),children:[q.jsx(It,{value:"false",children:"False"}),q.jsx(It,{value:"true",children:"True"})]}):y.valueType==="select"?q.jsx(Dt,{size:"sm",variant:"ghost",value:y.value,placeholder:"Select option",disabled:o,"aria-labelledby":G,onValueChange:F=>Q(y.id,{value:F}),children:(m.find(F=>F.key===y.key)?.options??[]).map(F=>q.jsx(It,{value:F.value,children:F.label},F.id))}):y.valueType==="url"?q.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[q.jsx(jt,{className:"min-w-0",size:"sm",variant:"ghost",type:"url","aria-label":"Property value",placeholder:"https://example.com",value:y.value,disabled:o,onChange:F=>Q(y.id,{value:F.target.value})}),K?q.jsx(kt,{asChild:!0,size:"icon-sm",variant:"ghost","aria-label":`Open ${y.name}`,className:"shrink-0 text-fg-tertiary",children:q.jsx("a",{href:K,target:"_blank",rel:"noopener noreferrer",title:K,children:q.jsx(ue,{className:"h-4 w-4"})})}):null]}):q.jsx(jt,{size:"sm",variant:"ghost",type:y.valueType==="date"?"date":y.valueType==="number"?"number":"text","aria-label":"Property value",placeholder:"Value",value:y.value,disabled:o,onChange:F=>Q(y.id,{value:F.target.value})}),q.jsx(kt,{type:"button",size:"icon-sm",variant:"ghost","aria-label":`Remove ${y.name}`,disabled:o,className:"justify-self-end text-fg-tertiary sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100",onClick:()=>Z(y),children:q.jsx(Qt,{className:"h-4 w-4"})})]},y.id)})}),q.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:V.isLoading?q.jsx(kt,{type:"button",size:"sm",variant:"ghost",disabled:!0,children:"Loading properties..."}):T.length>0?q.jsxs(te,{children:[q.jsx(ee,{asChild:!0,children:q.jsxs(kt,{type:"button",size:"sm",variant:"ghost",disabled:o,children:[q.jsx(Lt,{className:"h-4 w-4"}),"Add property"]})}),q.jsxs(re,{align:"start",sideOffset:6,className:"max-h-80 w-[min(22rem,calc(100vw-2rem))]",style:{overflowY:"auto"},children:[q.jsx(ne,{children:q.jsx(_t,{as:"span",variant:"label",weight:"semibold",children:"Add property"})}),q.jsx(ie,{}),T.map(y=>q.jsxs(ae,{className:"flex-col items-start gap-0.5 whitespace-normal",onClick:()=>U(y),children:[q.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-3",children:[q.jsx(_t,{as:"span",variant:"label",weight:"medium",className:"truncate",children:y.name}),q.jsx(_t,{as:"span",variant:"micro",tone:"tertiary",className:"shrink-0 capitalize",children:y.valueType})]}),q.jsx(_t,{as:"span",variant:"micro",tone:"tertiary",className:"font-mono",children:y.key})]},y.key))]})]}):e?q.jsx(_t,{as:"span",variant:"micro",tone:"tertiary",className:"px-1",children:"All shared properties are attached."}):q.jsxs(Ft,{to:Pt,search:{page:1},className:"focus-ring-soft inline-flex items-center gap-2 rounded-[12px] px-2.5 py-1.5 text-sm font-medium text-fg-secondary outline-none hover:bg-hover-subtle hover:text-fg-default",children:[q.jsx(Lt,{className:"h-4 w-4"}),"Create property definition"]})})]})});export{ce as A,ke as J,xe as N,he as a,ue as p};
@@ -0,0 +1 @@
1
+ import{r as e}from"./floating-ui.react-dom-wWLZ1CdM.js";import{R as l}from"./note.api-D_00ZzJC.js";const r=new Map([["bold",e.createElement(e.Fragment,null,e.createElement("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"}))],["duotone",e.createElement(e.Fragment,null,e.createElement("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"}),e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["fill",e.createElement(e.Fragment,null,e.createElement("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"}))],["light",e.createElement(e.Fragment,null,e.createElement("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"}))],["regular",e.createElement(e.Fragment,null,e.createElement("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"}))],["thin",e.createElement(e.Fragment,null,e.createElement("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"}))]]),a=e.forwardRef((t,n)=>e.createElement(l,{ref:n,...t,weights:r}));a.displayName="PlusIcon";const c=a;export{c as n};
@@ -0,0 +1 @@
1
+ import{j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";import{a4 as k,Z as h,ad as H,ah as M,aa as E,aj as w,al as S,ak as L,ac as o,ai as O}from"./note.api-D_00ZzJC.js";import{N as C,R as U}from"./url-BSnWpmJx.js";import{u as I,R as Y}from"./useReminderMutate-CLK1tHvT.js";import{M as B,i as u}from"./time-B3pt8vt4.js";const g={high:"bg-priority-high",medium:"bg-priority-medium",low:"bg-priority-low"};function P({reminder:t,onUpdate:l,onDelete:f}){const j=y=>{const r=u(Number(y)),m=u();return r.isSame(m,"day")?`Today at ${r.format("HH:mm")}`:r.isSame(m.add(1,"day"),"day")?`Tomorrow at ${r.format("HH:mm")}`:r.format("YYYY-MM-DD HH:mm")},i=y=>{const r=u(Number(y)),m=u(),N=r.diff(m,"hour"),b=r.diff(m,"minute")%60;return N<0||b<0?"Overdue":N===0?`${b}m remaining`:`${N}h ${b}m remaining`},d=i(t.reminderDate)==="Overdue",a=t.priority||"low",s=a==="high"?"High":a==="medium"?"Medium":"Low",p=g[a],c=t.noteId.toString(),n=d?"text-fg-error":"text-fg-tertiary",x=t.content?.trim()||t.note?.title||"Untitled reminder",v=t.note?.title||"Untitled note",T=!!(t.content?.trim()&&t.note?.title),D=i(t.reminderDate),$=j(t.reminderDate);return e.jsxs("div",{className:"surface-base flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-4",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2.5 sm:items-center",children:[e.jsx(k,{checked:t.completed,onChange:()=>l(t.id,c,{completed:!t.completed}),size:"sm","aria-label":`Reminder: ${x}`}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(h,{as:"p",variant:"body",weight:"semibold",className:t.completed?"truncate line-through opacity-45":"truncate",children:x}),T&&e.jsx(h,{as:"div",variant:"meta",tone:"secondary",className:t.completed?"mt-0.5 truncate opacity-45":"mt-0.5 truncate",children:e.jsx(H,{to:C,params:{id:String(t.note?.id??t.noteId)},className:"transition-colors hover:text-fg-default hover:underline",children:v})})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 sm:shrink-0",children:[e.jsx("span",{className:`h-3 w-3 shrink-0 rounded-full border border-border-subtle ${p}`,"aria-label":`${s} priority`,title:`${s} priority`}),e.jsx(h,{as:"span",variant:"meta",weight:"medium",tone:"secondary",className:t.completed?"opacity-45":void 0,children:$}),e.jsx("span",{className:"h-1 w-1 rounded-full bg-border-secondary"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",className:t.completed?"opacity-45":n,children:D})]}),e.jsx("div",{className:"flex items-center justify-end gap-1.5 sm:shrink-0",children:e.jsx(M,{button:e.jsx(B,{label:"Reminder actions",iconClassName:"h-5 w-5 text-current"}),items:[{name:"Delete",onClick:()=>f(t.id,c)}]})})]})}const R=O(U),A=[{label:"High",className:g.high},{label:"Medium",className:g.medium},{label:"Low",className:g.low}];function Z(){const t=R.useNavigate(),{page:l}=R.useSearch(),{onUpdate:f,onDelete:j}=I(),i=25,d=e.jsx("div",{className:"flex flex-wrap items-center gap-3",children:A.map(({label:a,className:s})=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full border border-border-subtle ${s}`,"aria-hidden":"true"}),e.jsx(h,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:a})]},a))});return e.jsx(E,{fallback:e.jsx(w,{title:"Reminders",heading:e.jsx(o,{width:164,height:24,className:"rounded-full"}),description:e.jsx(o,{width:224,height:16,className:"rounded-full"}),headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-2.5",children:[e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"}),e.jsx(o,{height:"60px"})]})}),errorTitle:"Failed to load reminders",errorDescription:"Retry loading the upcoming reminder list",resetKeys:[l,i],children:e.jsx(Y,{searchParams:{offset:(l-1)*i,limit:i},render:({reminders:a,totalCount:s})=>{const p=s>0?`Reminders (${s})`:void 0,c="Review reminders created from notes and mark them complete here";return a.length===0?e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsx(S,{title:"No upcoming reminders",description:"Add a reminder inside any note to see it here"})}):e.jsx(w,{title:"Reminders",heading:p,description:c,headerRight:d,children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-col gap-2.5",children:a.map(n=>e.jsx(P,{reminder:n,onUpdate:f,onDelete:j},n.id))}),s&&i<s&&e.jsx(L,{page:l,last:Math.ceil(s/i),onChange:n=>{t({search:x=>({...x,page:n})})}})]})})}})})}export{Z as default};
@@ -0,0 +1 @@
1
+ import{j as e,r as N}from"./floating-ui.react-dom-wWLZ1CdM.js";import{aj as u,al as f,aa as b,Z as h,ad as w,ak as S,ai as k,ac as d}from"./note.api-D_00ZzJC.js";import{N as E,S as $}from"./url-BSnWpmJx.js";import{N as R}from"./app-cTRcKMGc.js";import"./time-B3pt8vt4.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-D9GeO71k.js";const A=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=({children:t,match:s})=>{const r=s.trim();if(!r)return e.jsx("span",{children:t});const a=A(r),n=new RegExp(`(${a})`,"gi"),c=new RegExp(`^${a}$`,"i"),l=t.split(n);return e.jsx("span",{children:l.map((i,o)=>c.test(i)?e.jsx("mark",{children:i},o):e.jsx(N.Fragment,{children:i},o))})},j=k($),v=180,m=t=>t.replace(/\s+/g," ").trim(),L=(t,s)=>{const r=m(t),a=m(s).toLowerCase();if(!a)return r;const n=r.toLowerCase().indexOf(a);if(n===-1)return r.length>v?`${r.slice(0,v-1).trimEnd()}…`:r;const c=Math.max(0,n-56),l=Math.min(r.length,n+a.length+84);let i=r.slice(c,l).trim();return c>0&&(i=`…${i}`),l<r.length&&(i=`${i}…`),i},T=t=>Array.isArray(t)?t.map(s=>{if(!s||typeof s!="object")return"";const r=s.text;return typeof r=="string"?r:""}).join(""):"",B=(t,s)=>t==="heading"?`Heading ${typeof s?.level=="number"?s.level:1}`:t==="bulletListItem"?"Bullet":t==="numberedListItem"?"Numbered":t==="checkListItem"?"Checklist":t==="quote"?"Quote":t==="codeBlock"?"Code":"Content",y=(t,s)=>{Array.isArray(t)&&t.forEach(r=>{if(!r||typeof r!="object")return;const a=typeof r.type=="string"?r.type:void 0,n=typeof r.props=="object"&&r.props?r.props:void 0,c=m(T(r.content));c&&s.push({label:B(a,n),text:c});const l=r.children;Array.isArray(l)&&y(l,s)})},C=(t,s)=>{try{const r=JSON.parse(t),a=[];if(y(r,a),a.length===0)return[];const n=m(s).toLowerCase(),c=n?a.filter(i=>i.text.toLowerCase().includes(n)):a;return(c.length>0?c:a).slice(0,2).map(i=>({...i,text:L(i.text,s)}))}catch{return[]}},P=t=>t===1?"1 result":`${t} results`,M=()=>"Open the note to inspect matching content.",z=(t,s)=>`${P(s)} for "${t}"`,I=()=>e.jsx(u,{title:"Search",variant:"default",description:e.jsx(d,{width:208,height:16,className:"rounded-full"}),children:e.jsx("main",{className:"flex flex-col gap-3",children:Array.from({length:2},(t,s)=>e.jsxs("div",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(d,{width:"34%",height:18,className:"rounded-full"}),e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{children:[e.jsx(d,{width:84,height:12,className:"rounded-full"}),e.jsx(d,{width:"100%",height:14,className:"mt-2 rounded-full"}),e.jsx(d,{width:"82%",height:14,className:"mt-1.5 rounded-full"})]}),e.jsxs("div",{className:"border-t border-border-subtle pt-2",children:[e.jsx(d,{width:72,height:12,className:"rounded-full"}),e.jsx(d,{width:"94%",height:14,className:"mt-2 rounded-full"})]})]})})]},s))})});function D(){const t=j.useNavigate(),{page:s,query:r}=j.useSearch(),a=r.trim(),n=10;return a?e.jsx(b,{fallback:e.jsx(I,{}),errorTitle:"Failed to load search results",errorDescription:`Retry loading results for "${a}".`,resetKeys:[a,s],children:e.jsx(R,{searchParams:{query:a,limit:n,offset:(s-1)*n,fields:["content"]},render:({notes:c,totalCount:l})=>e.jsx(u,{title:"Search",description:z(a,l),variant:"default",children:e.jsxs("main",{className:"flex flex-col gap-4",children:[c.length>0?e.jsx("div",{className:"flex flex-col gap-3",children:c.map(i=>{const o=C(i.content,a);return e.jsxs("article",{className:"surface-base flex flex-col gap-3 p-4",children:[e.jsx(h,{as:"h2",variant:"body",weight:"semibold",tracking:"tight",children:e.jsx(w,{to:E,params:{id:i.id},className:"transition-colors hover:text-fg-default/85",children:e.jsx(g,{match:a,children:i.title||"Untitled"})})}),o.length>0?e.jsx("div",{className:"rounded-[14px] bg-muted px-3 py-3",children:e.jsx("div",{className:"flex flex-col gap-2",children:o.map((x,p)=>e.jsxs("div",{className:p>0?"border-t border-border-subtle pt-2":void 0,children:[e.jsx(h,{as:"div",variant:"micro",weight:"semibold",tracking:"wider",transform:"uppercase",tone:"tertiary",children:x.label}),e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"mt-1 leading-[1.65]",children:e.jsx(g,{match:a,children:x.text})})]},`${i.id}:${x.label}:${p}`))})}):e.jsx(h,{as:"p",variant:"meta",tone:"secondary",className:"leading-[1.65]",children:M()})]},i.id)})}):e.jsx(f,{title:"No results found",description:"Try searching for a different word or phrase"}),l>n&&e.jsx(S,{page:s,last:Math.ceil(l/n),onChange:i=>{t({search:o=>({...o,page:i})})}})]})})})}):e.jsx(u,{title:"Search",description:"Search note titles and matching sections across your workspace",variant:"default",children:e.jsx("main",{children:e.jsx(f,{title:"Start searching",description:"Enter a keyword to look through note titles and matching content"})})})}export{D as default};
@@ -0,0 +1 @@
1
+ import{j as f}from"./floating-ui.react-dom-wWLZ1CdM.js";import{aZ as o}from"./note.api-D_00ZzJC.js";const n=o("surface-base",{variants:{tone:{default:"",elevated:"surface-elevated"},padding:{default:"p-4",compact:"px-3 py-2.5",roomy:"p-6",flush:"overflow-hidden"}},defaultVariants:{tone:"default",padding:"default"}});function i({children:a,className:e,flush:t=!1,padding:d="default",tone:s="default"}){const r=t?"flush":d;return f.jsx("div",{className:n({tone:s,padding:r,className:e}),children:a})}export{i as S};
@@ -0,0 +1 @@
1
+ import{r as p,j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";import{a9 as T,T as S,aj as k,Z as d,a7 as P,_ as y,a0 as x,aa as q,ad as E,ak as A,al as O,ac as o,ai as C}from"./note.api-D_00ZzJC.js";import{g as L,i as _,T as I,j as R,k as F,l as Q,F as v}from"./app-cTRcKMGc.js";import{b as B,T as D}from"./url-BSnWpmJx.js";import{f as z}from"./tag.api-CX0SE06J.js";import{f as G}from"./Graph-D9GeO71k.js";import"./time-B3pt8vt4.js";import"./preload-helper-BXl3LOEh.js";const M=s=>{const{data:h}=T({queryKey:S.tags.list(s.searchParams),async queryFn(){const t=await z({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit,sortBy:s.searchParams.sortBy,sortOrder:s.searchParams.sortOrder});if(t.type==="error")throw t;return t.allTags}});return s.render(h)},b=C(D);function X(){const s=b.useNavigate(),{page:h,query:t,limit:l,sortBy:n,sortOrder:m}=b.useSearch(),[u,f]=p.useState(t),[,j]=L(350),i=t.trim();p.useEffect(()=>{f(t)},[t]),p.useEffect(()=>{const a=u.trim();a!==i&&j(()=>{s({search:r=>({...r,page:1,query:a})})})},[u,s,i,j]);const g=a=>{s({search:r=>({...r,...a})})},w=()=>{f(""),g({page:1,query:""})};return e.jsxs(k,{title:"Tags",description:"Find tags you added with @ across your notes",children:[e.jsxs("div",{className:"mb-5 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{className:"surface-base flex min-w-0 items-center gap-2 rounded-[16px] px-3.5 py-2.5 lg:w-72",children:[e.jsx(G,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Search"}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsx("input",{"aria-label":"Search tags",placeholder:"Search tags",value:u,onChange:a=>f(a.target.value),className:"h-8 min-w-0 flex-1 bg-transparent text-sm font-medium text-fg-default outline-none placeholder:text-xs placeholder:font-medium placeholder:text-fg-placeholder"}),(u||i)&&e.jsx("button",{type:"button","aria-label":"Clear tag search",className:"focus-ring-soft flex h-7 w-7 shrink-0 items-center justify-center rounded-[10px] text-fg-tertiary outline-none transition-colors hover:bg-hover-subtle hover:text-fg-default",onClick:w,children:e.jsx(P,{className:"h-3.5 w-3.5",weight:"bold"})})]}),e.jsxs("div",{className:"surface-base inline-flex flex-wrap items-center gap-3 rounded-[16px] px-3.5 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Items"}),e.jsx(y,{value:String(l),onValueChange:a=>{const r=Number(a);F(r)&&g({limit:r,page:1})},variant:"ghost",size:"sm",children:I.map(a=>e.jsx(x,{value:String(a),children:a===R?`Default (${a})`:a},a))})]}),e.jsx("div",{className:"h-5 w-px bg-divider"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 shrink-0 text-fg-tertiary"}),e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",children:"Sort"}),e.jsxs(y,{value:n,onValueChange:a=>g({sortBy:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(x,{value:"referenceCount",children:"Usage"}),e.jsx(x,{value:"name",children:"Name"})]}),e.jsxs(y,{value:m,onValueChange:a=>g({sortOrder:a,page:1}),variant:"ghost",size:"sm",children:[e.jsx(x,{value:"desc",children:n==="name"?"Z to A":"Most used"}),e.jsx(x,{value:"asc",children:n==="name"?"A to Z":"Least used"})]})]})]})]}),e.jsx(q,{fallback:e.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[e.jsx(o,{width:"90px",height:"36px"}),e.jsx(o,{width:"120px",height:"36px"}),e.jsx(o,{width:"80px",height:"36px"}),e.jsx(o,{width:"100px",height:"36px"}),e.jsx(o,{width:"110px",height:"36px"}),e.jsx(o,{width:"70px",height:"36px"})]}),errorTitle:"Failed to load tags",errorDescription:"Retry loading the tag catalog",resetKeys:[h,l,i,n,m],children:e.jsx(M,{searchParams:{query:i,offset:(h-1)*l,limit:l,sortBy:n,sortOrder:m},render:({tags:a,totalCount:r})=>e.jsx(v,{fallback:e.jsx(O,{title:i?"No matching tags":"No tags yet",description:i?"Try another tag name":"Add @tags inside notes and they will appear here"}),children:a.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"flex flex-wrap gap-2.5",children:a.map(c=>e.jsxs(E,{to:B,params:{id:c.id},search:{page:1},className:"inline-flex items-center gap-1.5 rounded-full border border-border-subtle bg-hover-subtle px-3 py-1.5 text-fg-secondary transition-colors hover:border-border-secondary hover:bg-hover hover:text-fg-default",children:[e.jsx(d,{as:"span",variant:"meta",weight:"medium",className:"text-current",children:c.name}),e.jsx(d,{as:"span",variant:"label",weight:"medium",tone:"tertiary",className:"text-current/70",children:c.referenceCount})]},c.id))}),e.jsx(v,{fallback:null,children:r&&l<r&&e.jsx(A,{page:h,last:Math.ceil(r/l),onChange:c=>{s({search:N=>({...N,page:c,query:i,limit:l,sortBy:n,sortOrder:m})})}})})]})})})})]})}export{X as default};
@@ -0,0 +1 @@
1
+ import{j as e}from"./floating-ui.react-dom-wWLZ1CdM.js";import{a9 as x,a$ as j,T as y,aa as N,aj as c,ak as T,al as P,ac as o,ai as v}from"./note.api-D_00ZzJC.js";import{F as h,n as k}from"./app-cTRcKMGc.js";import{b as w}from"./url-BSnWpmJx.js";import"./NotePropertiesPanel-2DgXEM4B.js";import{f as b}from"./time-B3pt8vt4.js";import"./preload-helper-BXl3LOEh.js";import"./Graph-D9GeO71k.js";import"./Plus.es-CQ8wn2is.js";const q=s=>{const{data:r}=x({queryKey:y.notes.tagList(s.searchParams),async queryFn(){const t=await j({query:s.searchParams.query,offset:s.searchParams.offset,limit:s.searchParams.limit});if(t.type==="error")throw t;return t.tagNotes}});return s.render(r)},g=v(w);function A(){const s=g.useNavigate(),{id:r}=g.useParams(),{page:t}=g.useSearch(),i=25,{onDelete:m,onPinned:u,deleteWarningDialog:f}=b();return e.jsxs(N,{fallback:e.jsx(c,{title:"Tagged Notes",heading:e.jsx(o,{width:148,height:24,className:"rounded-full"}),description:e.jsx(o,{width:196,height:16,className:"rounded-full"}),variant:"default",children:e.jsxs("div",{className:"grid-auto-cards grid gap-5",children:[e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"}),e.jsx(o,{height:"112px"})]})}),errorTitle:"Failed to load tagged notes",errorDescription:"Retry loading notes for this tag",resetKeys:[r,t,i],children:[e.jsx(q,{searchParams:{query:r,offset:(t-1)*i,limit:i},render:({notes:l,totalCount:n})=>{const d=l.flatMap(a=>a.tags).find(a=>a.id===r)?.name;return e.jsx(c,{title:d??"Tagged Notes",heading:d?n>0?`${d} (${n})`:d:"Tagged Notes",description:"Browse every note linked to this tag",variant:"default",children:e.jsx(h,{fallback:e.jsx(P,{title:"No tagged notes yet",description:"Notes tagged with this label will appear here"}),children:l.length>0&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"grid-auto-cards grid gap-5",children:l.map(a=>e.jsx(k,{...a,onPinned:()=>u(a.id,a.pinned),onDelete:()=>m(a.id)},a.id))}),e.jsx(h,{fallback:null,children:n&&i<n&&e.jsx(T,{page:t,last:Math.ceil(n/i),onChange:a=>{s({search:p=>({...p,page:a})})}})})]})})})}}),f]})}export{A as default};