tauri-notice-window 1.0.2 → 1.0.3

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.
package/README.md CHANGED
@@ -193,9 +193,13 @@ Wrapper component for notice pages that loads the message and provides it to chi
193
193
  interface NoticeLayoutProps {
194
194
  children: (message: MessageType) => ReactNode
195
195
  onLoad?: (message: MessageType) => void
196
+ onClose?: (message: MessageType) => void
196
197
  }
197
198
 
198
- <NoticeLayout onLoad={(msg) => console.log('Loaded:', msg)}>
199
+ <NoticeLayout
200
+ onLoad={(msg) => console.log('Loaded:', msg)}
201
+ onClose={(msg) => console.log('Closing:', msg)}
202
+ >
199
203
  {(message) => <YourCustomUI message={message} />}
200
204
  </NoticeLayout>
201
205
  ```
@@ -12,11 +12,15 @@ interface NoticeLayoutProps {
12
12
  * Optional callback when message is loaded
13
13
  */
14
14
  onLoad?: (message: MessageType) => void;
15
+ /**
16
+ * Optional callback when window is closed
17
+ */
18
+ onClose?: (message: MessageType) => void;
15
19
  }
16
20
  /**
17
21
  * Layout component for notice windows
18
22
  * Loads the message from database/URL and provides it to children
19
23
  */
20
- export declare const NoticeLayout: ({ children, onLoad }: NoticeLayoutProps) => import("react/jsx-runtime").JSX.Element;
24
+ export declare const NoticeLayout: ({ children, onLoad, onClose }: NoticeLayoutProps) => import("react/jsx-runtime").JSX.Element;
21
25
  export {};
22
26
  //# sourceMappingURL=NoticeLayout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"NoticeLayout.d.ts","sourceRoot":"","sources":["../../src/components/NoticeLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD;;GAEG;AACH,UAAU,iBAAiB;IACzB;;OAEG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAA;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;CACxC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,sBAAsB,iBAAiB,4CA0EnE,CAAA"}
1
+ {"version":3,"file":"NoticeLayout.d.ts","sourceRoot":"","sources":["../../src/components/NoticeLayout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAGnD;;GAEG;AACH,UAAU,iBAAiB;IACzB;;OAEG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,SAAS,CAAA;IAC7C;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;IACvC;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAA;CACzC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,+BAA+B,iBAAiB,4CAyF5E,CAAA"}
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ge=require("zustand"),be=require("zustand-sync"),ye=require("dexie"),b=require("react"),D=require("react/jsx-runtime"),J="tauri-notice-config",B={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300},Z=()=>{try{const t=localStorage.getItem(J);if(t)return{...B,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return B},pe=t=>{try{localStorage.setItem(J,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},_e=t=>{const i={...Z(),...t};pe(i)},R=()=>Z();class fe extends ye{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let v=null;const E=()=>{if(!v){const t=R();v=new fe(t.databaseName)}return v},h=()=>v||E(),Y=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await h().messages.put(e)},K=async t=>!!await h().messages.get(t),X=async()=>await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),me=async(t,e)=>{await h().messages.update(t,{queueStatus:e})},ee=async t=>{await h().messages.update(t,{queueStatus:"shown",isShown:!0})},te=async t=>{await h().messages.update(t,{queueStatus:"hidden"})},ie=async t=>await h().messages.get(t),ne=async()=>{await h().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},ve=async t=>{const e=t.map(i=>h().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},We=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await K(i.id)||await Y(i),!n.queue.some(l=>l.id===i.id)){const l=[...n.queue,i];t({queue:l}),await e().persistQueue()}!n.isProcessing&&!n.currentMessage&&await e().showNext()},dequeue:()=>{const i=e();if(i.queue.length===0)return null;const[n,...a]=i.queue;return t({queue:a}),n},showNext:async()=>{if(e().isProcessing)return;const n=e().dequeue();if(!n){t({isProcessing:!1,currentMessage:null});return}t({currentMessage:n,isProcessing:!0}),await me(n.id,"showing"),await e().persistQueue()},clearCurrent:()=>{t({currentMessage:null,isProcessing:!1}),e().queue.length>0&&e().showNext()},setCurrentMessage:i=>{t({currentMessage:i})},setIsProcessing:i=>{t({isProcessing:i})},setQueue:i=>{t({queue:i})},initializeFromDatabase:async()=>{if(e().initialized)return;t({initialized:!0});const n=await X();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,r)=>({id:a.id,position:r}));await ve(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await ne()},addActiveWindow:i=>{const n=e(),a=String(i);n.activeWindowIds.includes(a)||t({activeWindowIds:[...n.activeWindowIds,a]})},removeActiveWindow:i=>{const n=e(),a=String(i);t({activeWindowIds:n.activeWindowIds.filter(r=>r!==a)})},isWindowActive:i=>{const n=e(),a=String(i);return n.activeWindowIds.includes(a)}}),d=ge.create()(be.syncTabs(We,{name:"tauri-notice-queue"})),m={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},Se=()=>{const t=d(i=>i.enqueue);return{showNotice:b.useCallback(async i=>{await t(i)},[t])}};function Ne(t,e,i,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function De(t,e,i,n,a){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}var z;const w="__TAURI_TO_IPC_KEY__";function ze(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},i){return window.__TAURI_INTERNALS__.invoke(t,e,i)}class Ae{get rid(){return Ne(this,z,"f")}constructor(e){z.set(this,void 0),De(this,z,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}z=new WeakMap;class se{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new y(this.width*e,this.height*e)}[w](){return{width:this.width,height:this.height}}toJSON(){return this[w]()}}class y{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new se(this.width/e,this.height/e)}[w](){return{width:this.width,height:this.height}}toJSON(){return this[w]()}}class g{constructor(e){this.size=e}toLogical(e){return this.size instanceof se?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof y?this.size:this.size.toPhysical(e)}[w](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[w]()}}class ae{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new u(this.x*e,this.y*e)}[w](){return{x:this.x,y:this.y}}toJSON(){return this[w]()}}class u{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new ae(this.x/e,this.y/e)}[w](){return{x:this.x,y:this.y}}toJSON(){return this[w]()}}class _{constructor(e){this.position=e}toLogical(e){return this.position instanceof ae?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof u?this.position:this.position.toPhysical(e)}[w](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[w]()}}var o;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(o||(o={}));async function le(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function O(t,e,i){var n;const a=typeof i?.target=="string"?{kind:"AnyLabel",label:i.target}:(n=i?.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:a,handler:ze(e)}).then(r=>async()=>le(t,r))}async function T(t,e,i){return O(t,n=>{le(t,n.id),e(n)},i)}async function re(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function oe(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class W extends Ae{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:A(e),width:i,height:n}).then(a=>new W(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:A(e)}).then(i=>new W(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new W(i))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}function A(t){return t==null?null:typeof t=="string"?t:t instanceof W?t.rid:t}var L;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(L||(L={}));class Oe{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var G;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(G||(G={}));function ue(){return new P(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function I(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new P(e,{skip:!0})))}const k=["tauri://created","tauri://error"];class P{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:window|create",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await I()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return ue()}static async getAll(){return I()}static async getFocusedWindow(){for(const e of await I())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:O(e,i,{target:{kind:"Window",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:T(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(k.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return re(e,i)}async emitTo(e,i,n){if(k.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return oe(e,i,n)}_handleTauriEvent(e,i){return k.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new u(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new u(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new y(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new y(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===L.Critical?i={type:"Critical"}:i={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:i})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof g?e:new g(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof g?e:e?new g(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof g?e:e?new g(e):null})}async setSizeConstraints(e){function i(n){return n?{Logical:n}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:i(e?.minWidth),minHeight:i(e?.minHeight),maxWidth:i(e?.maxWidth),maxHeight:i(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:A(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?A(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(o.WINDOW_RESIZED,i=>{i.payload=new y(i.payload),e(i)})}async onMoved(e){return this.listen(o.WINDOW_MOVED,i=>{i.payload=new u(i.payload),e(i)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async i=>{const n=new Oe(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new u(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new u(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new u(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}async onFocusChanged(e){const i=await this.listen(o.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(o.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(o.WINDOW_THEME_CHANGED,e)}}var H;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(H||(H={}));var U;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(U||(U={}));var Q;(function(t){t.AppearanceBased="appearanceBased",t.Light="light",t.Dark="dark",t.MediumLight="mediumLight",t.UltraDark="ultraDark",t.Titlebar="titlebar",t.Selection="selection",t.Menu="menu",t.Popover="popover",t.Sidebar="sidebar",t.HeaderView="headerView",t.Sheet="sheet",t.WindowBackground="windowBackground",t.HudWindow="hudWindow",t.FullScreenUI="fullScreenUI",t.Tooltip="tooltip",t.ContentBackground="contentBackground",t.UnderWindowBackground="underWindowBackground",t.UnderPageBackground="underPageBackground",t.Mica="mica",t.Blur="blur",t.Acrylic="acrylic",t.Tabbed="tabbed",t.TabbedDark="tabbedDark",t.TabbedLight="tabbedLight"})(Q||(Q={}));var j;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(j||(j={}));function Pe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new u(t.position),size:new y(t.size),workArea:{position:new u(t.workArea.position),size:new y(t.workArea.size)}}}async function xe(){return s("plugin:window|primary_monitor").then(Pe)}function ce(){return new q(ue(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function V(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new q(new P(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const M=["tauri://created","tauri://error"];class q{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...n,label:i}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await V()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return ce()}static async getAll(){return V()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:O(e,i,{target:{kind:"Webview",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:T(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(M.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return re(e,i)}async emitTo(e,i,n){if(M.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return oe(e,i,n)}_handleTauriEvent(e,i){return M.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new u(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new y(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof g?e:new g(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new u(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new u(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new u(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}}function Ce(){const t=ce();return new f(t.label,{skip:!0})}async function $(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new f(e,{skip:!0})))}class f{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview_window",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;const n=(i=(await $()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new f(n.label,{skip:!0}):null}static getCurrent(){return Ce()}static async getAll(){return $()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:O(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:T(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}}Ie(f,[P,q]);function Ie(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var a;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(a=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&a!==void 0?a:Object.create(null))})})}const S=new Map,ke=async(t,e,i)=>{const n=i?.padding??20;if(i?.x!==void 0&&i?.y!==void 0)return{x:i.x,y:i.y};let a=1920,r=1080;try{const c=await xe();c?.size&&(a=c.size.width,r=c.size.height)}catch(c){console.warn("Failed to get monitor info, using defaults:",c)}switch(i?.position??"right-bottom"){case"right-bottom":return{x:a-t-n,y:r-e-n};case"right-top":return{x:a-t-n,y:n};case"left-bottom":return{x:n,y:r-e-n};case"left-top":return{x:n,y:n};case"center":return{x:(a-t)/2,y:(r-e)/2};default:return{x:a-t-n,y:r-e-n}}},de=async t=>{const e=String(t.id),i=d.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=R(),a=`notice-${e}`,r=`${n.routePrefix}/${t.type}?id=${t.id}`,l=t.min_width||n.defaultWidth,c=t.min_height||n.defaultHeight,{x:F,y:N}=await ke(l,c,t.windowPosition);try{const p=new f(a,{url:r,title:t.title,width:l,height:c,x:F,y:N,resizable:!0,decorations:!0,skipTaskbar:!1,alwaysOnTop:!0});S.set(e,p),i.addActiveWindow(e),p.once("tauri://destroyed",async()=>{S.delete(e),i.removeActiveWindow(e),await ee(e),i.clearCurrent()}),console.log(`Created notice window: ${a}`)}catch(p){console.error("Failed to create notice window:",p),i.removeActiveWindow(e),i.clearCurrent()}},x=async t=>{const e=String(t),i=S.get(e);if(i)try{await i.close(),S.delete(e),console.log(`Closed notice window: ${e}`)}catch(n){console.error("Failed to close notice window:",n)}},we=async()=>{const t=Array.from(S.keys()).map(e=>x(e));await Promise.all(t)},he=()=>{let t=null;d.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,de(i)):i||(t=null)}),console.log("Notice window system initialized")},Me=()=>{const t=d(i=>i.currentMessage);return{closeNotice:b.useCallback(async()=>{t&&await x(t.id)},[t])}},Le=()=>{const t=d();return{hideNotice:b.useCallback(async i=>{await te(i),await x(i),t.currentMessage?.id===i&&t.clearCurrent()},[t])}},Re=()=>{const t=d(i=>i.clearOnLogout);return{hideAllNotices:b.useCallback(async()=>{await we(),await t()},[t])}},Ee=()=>{const t=d(m.queueLength),e=d(m.currentMessage),i=d(m.isProcessing),n=d(m.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},Te=({children:t,onLoad:e})=>{const[i,n]=b.useState(null),[a,r]=b.useState(!0),[l,c]=b.useState(null);return b.useEffect(()=>{(async()=>{try{const p=new URLSearchParams(window.location.search).get("id");if(!p){c("No message ID provided"),r(!1);return}const C=await ie(p);if(!C){c("Message not found"),r(!1);return}n(C),r(!1),e&&e(C)}catch(N){console.error("Failed to load message:",N),c("Failed to load message"),r(!1)}})()},[e]),a?D.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):l||!i?D.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:l||"Message not found"}):D.jsx(D.Fragment,{children:t(i)})},qe=async()=>{E(),he();const{initializeFromDatabase:t}=d.getState();await t(),console.log("Tauri Notice System initialized")};exports.NoticeLayout=Te;exports.clearPendingMessages=ne;exports.closeAllNoticeWindows=we;exports.closeNoticeWindow=x;exports.createNoticeWindow=de;exports.getMessage=ie;exports.getNoticeConfig=R;exports.getPendingMessages=X;exports.hasMessage=K;exports.initializeDatabase=E;exports.initializeNoticeSystem=qe;exports.initializeNoticeWindowSystem=he;exports.markAsHidden=te;exports.markAsShown=ee;exports.messageQueueSelectors=m;exports.saveMessage=Y;exports.setNoticeConfig=_e;exports.useCloseNotice=Me;exports.useHideAllNotices=Re;exports.useHideNotice=Le;exports.useMessageQueue=Ee;exports.useMessageQueueStore=d;exports.useNoticeWindow=Se;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const be=require("zustand"),ye=require("zustand-sync"),pe=require("dexie"),h=require("react"),z=require("react/jsx-runtime"),Z="tauri-notice-config",G={routePrefix:"/notice",databaseName:"tauri-notice-db",defaultWidth:400,defaultHeight:300},Y=()=>{try{const t=localStorage.getItem(Z);if(t)return{...G,...JSON.parse(t)}}catch(t){console.warn("Failed to load config from localStorage:",t)}return G},_e=t=>{try{localStorage.setItem(Z,JSON.stringify(t))}catch(e){console.warn("Failed to save config to localStorage:",e)}},fe=t=>{const i={...Y(),...t};_e(i)},E=()=>Y();class me extends pe{messages;constructor(e){super(e),this.version(1).stores({messages:"id, queueStatus, queuePosition, timestamp"})}}let S=null;const T=()=>{if(!S){const t=E();S=new me(t.databaseName)}return S},g=()=>S||T(),K=async t=>{const e={...t,timestamp:new Date().toISOString(),isRead:!1,isShown:!1,queueStatus:"pending",queuePosition:0};await g().messages.put(e)},X=async t=>!!await g().messages.get(t),ee=async()=>await g().messages.where("queueStatus").equals("pending").sortBy("queuePosition"),ve=async(t,e)=>{await g().messages.update(t,{queueStatus:e})},te=async t=>{await g().messages.update(t,{queueStatus:"shown",isShown:!0})},ie=async t=>{await g().messages.update(t,{queueStatus:"hidden"})},ne=async t=>await g().messages.get(t),se=async()=>{await g().messages.where("queueStatus").anyOf(["pending","showing"]).delete()},We=async t=>{const e=t.map(i=>g().messages.update(i.id,{queuePosition:i.position}));await Promise.all(e)},Se=(t,e)=>({queue:[],currentMessage:null,isProcessing:!1,initialized:!1,activeWindowIds:[],enqueue:async i=>{const n=e();if(await X(i.id)||await K(i),!n.queue.some(l=>l.id===i.id)){const l=[...n.queue,i];t({queue:l}),await e().persistQueue()}!n.isProcessing&&!n.currentMessage&&await e().showNext()},dequeue:()=>{const i=e();if(i.queue.length===0)return null;const[n,...a]=i.queue;return t({queue:a}),n},showNext:async()=>{if(e().isProcessing)return;const n=e().dequeue();if(!n){t({isProcessing:!1,currentMessage:null});return}t({currentMessage:n,isProcessing:!0}),await ve(n.id,"showing"),await e().persistQueue()},clearCurrent:()=>{t({currentMessage:null,isProcessing:!1}),e().queue.length>0&&e().showNext()},setCurrentMessage:i=>{t({currentMessage:i})},setIsProcessing:i=>{t({isProcessing:i})},setQueue:i=>{t({queue:i})},initializeFromDatabase:async()=>{if(e().initialized)return;t({initialized:!0});const n=await ee();n.length>0&&(t({queue:n}),await e().showNext())},persistQueue:async()=>{const n=e().queue.map((a,r)=>({id:a.id,position:r}));await We(n)},clearOnLogout:async()=>{t({queue:[],currentMessage:null,isProcessing:!1,activeWindowIds:[],initialized:!1}),await se()},addActiveWindow:i=>{const n=e(),a=String(i);n.activeWindowIds.includes(a)||t({activeWindowIds:[...n.activeWindowIds,a]})},removeActiveWindow:i=>{const n=e(),a=String(i);t({activeWindowIds:n.activeWindowIds.filter(r=>r!==a)})},isWindowActive:i=>{const n=e(),a=String(i);return n.activeWindowIds.includes(a)}}),c=be.create()(ye.syncTabs(Se,{name:"tauri-notice-queue"})),W={queueLength:t=>t.queue.length,currentMessage:t=>t.currentMessage,isProcessing:t=>t.isProcessing,queue:t=>t.queue},Ne=()=>{const t=c(i=>i.enqueue);return{showNotice:h.useCallback(async i=>{await t(i)},[t])}};function De(t,e,i,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?n:i==="a"?n.call(t):n?n.value:e.get(t)}function ze(t,e,i,n,a){if(typeof e=="function"?t!==e||!0:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,i),i}var A;const d="__TAURI_TO_IPC_KEY__";function Ae(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},i){return window.__TAURI_INTERNALS__.invoke(t,e,i)}class Oe{get rid(){return De(this,A,"f")}constructor(e){A.set(this,void 0),ze(this,A,e)}async close(){return s("plugin:resources|close",{rid:this.rid})}}A=new WeakMap;class ae{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new y(this.width*e,this.height*e)}[d](){return{width:this.width,height:this.height}}toJSON(){return this[d]()}}class y{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new ae(this.width/e,this.height/e)}[d](){return{width:this.width,height:this.height}}toJSON(){return this[d]()}}class b{constructor(e){this.size=e}toLogical(e){return this.size instanceof ae?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof y?this.size:this.size.toPhysical(e)}[d](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[d]()}}class le{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new u(this.x*e,this.y*e)}[d](){return{x:this.x,y:this.y}}toJSON(){return this[d]()}}class u{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new le(this.x/e,this.y/e)}[d](){return{x:this.x,y:this.y}}toJSON(){return this[d]()}}class _{constructor(e){this.position=e}toLogical(e){return this.position instanceof le?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof u?this.position:this.position.toPhysical(e)}[d](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[d]()}}var o;(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(o||(o={}));async function re(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function P(t,e,i){var n;const a=typeof i?.target=="string"?{kind:"AnyLabel",label:i.target}:(n=i?.target)!==null&&n!==void 0?n:{kind:"Any"};return s("plugin:event|listen",{event:t,target:a,handler:Ae(e)}).then(r=>async()=>re(t,r))}async function q(t,e,i){return P(t,n=>{re(t,n.id),e(n)},i)}async function oe(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ue(t,e,i){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:i})}class N extends Oe{constructor(e){super(e)}static async new(e,i,n){return s("plugin:image|new",{rgba:O(e),width:i,height:n}).then(a=>new N(a))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:O(e)}).then(i=>new N(i))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(i=>new N(i))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}function O(t){return t==null?null:typeof t=="string"?t:t instanceof N?t.rid:t}var R;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(R||(R={}));class Pe{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}}var H;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(H||(H={}));function ce(){return new x(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function M(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new x(e,{skip:!0})))}const C=["tauri://created","tauri://error"];class x{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:window|create",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await M()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return ce()}static async getAll(){return M()}static async getFocusedWindow(){for(const e of await M())if(await e.isFocused())return e;return null}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:P(e,i,{target:{kind:"Window",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:q(e,i,{target:{kind:"Window",label:this.label}})}async emit(e,i){if(C.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return oe(e,i)}async emitTo(e,i,n){if(C.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ue(e,i,n)}_handleTauriEvent(e,i){return C.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new u(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new u(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new y(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new y(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let i=null;return e&&(e===R.Critical?i={type:"Critical"}:i={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:i})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof b?e:new b(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof b?e:e?new b(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof b?e:e?new b(e):null})}async setSizeConstraints(e){function i(n){return n?{Logical:n}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:i(e?.minWidth),minHeight:i(e?.minHeight),maxWidth:i(e?.maxWidth),maxHeight:i(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:O(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?O(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(o.WINDOW_RESIZED,i=>{i.payload=new y(i.payload),e(i)})}async onMoved(e){return this.listen(o.WINDOW_MOVED,i=>{i.payload=new u(i.payload),e(i)})}async onCloseRequested(e){return this.listen(o.WINDOW_CLOSE_REQUESTED,async i=>{const n=new Pe(i);await e(n),n.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new u(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new u(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new u(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}async onFocusChanged(e){const i=await this.listen(o.WINDOW_FOCUS,a=>{e({...a,payload:!0})}),n=await this.listen(o.WINDOW_BLUR,a=>{e({...a,payload:!1})});return()=>{i(),n()}}async onScaleChanged(e){return this.listen(o.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(o.WINDOW_THEME_CHANGED,e)}}var U;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(U||(U={}));var Q;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(Q||(Q={}));var j;(function(t){t.AppearanceBased="appearanceBased",t.Light="light",t.Dark="dark",t.MediumLight="mediumLight",t.UltraDark="ultraDark",t.Titlebar="titlebar",t.Selection="selection",t.Menu="menu",t.Popover="popover",t.Sidebar="sidebar",t.HeaderView="headerView",t.Sheet="sheet",t.WindowBackground="windowBackground",t.HudWindow="hudWindow",t.FullScreenUI="fullScreenUI",t.Tooltip="tooltip",t.ContentBackground="contentBackground",t.UnderWindowBackground="underWindowBackground",t.UnderPageBackground="underPageBackground",t.Mica="mica",t.Blur="blur",t.Acrylic="acrylic",t.Tabbed="tabbed",t.TabbedDark="tabbedDark",t.TabbedLight="tabbedLight"})(j||(j={}));var V;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(V||(V={}));function xe(t){return t===null?null:{name:t.name,scaleFactor:t.scaleFactor,position:new u(t.position),size:new y(t.size),workArea:{position:new u(t.workArea.position),size:new y(t.workArea.size)}}}async function Ie(){return s("plugin:window|primary_monitor").then(xe)}function de(){return new F(ce(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function $(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new F(new x(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}const L=["tauri://created","tauri://error"];class F{constructor(e,i,n){this.window=e,this.label=i,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...n,label:i}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;return(i=(await $()).find(n=>n.label===e))!==null&&i!==void 0?i:null}static getCurrent(){return de()}static async getAll(){return $()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:P(e,i,{target:{kind:"Webview",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:q(e,i,{target:{kind:"Webview",label:this.label}})}async emit(e,i){if(L.includes(e)){for(const n of this.listeners[e]||[])n({event:e,id:-1,payload:i});return}return oe(e,i)}async emitTo(e,i,n){if(L.includes(i)){for(const a of this.listeners[i]||[])a({event:i,id:-1,payload:n});return}return ue(e,i,n)}_handleTauriEvent(e,i){return L.includes(e)?(e in this.listeners?this.listeners[e].push(i):this.listeners[e]=[i],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new u(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new y(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof b?e:new b(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof _?e:new _(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){const i=await this.listen(o.DRAG_ENTER,l=>{e({...l,payload:{type:"enter",paths:l.payload.paths,position:new u(l.payload.position)}})}),n=await this.listen(o.DRAG_OVER,l=>{e({...l,payload:{type:"over",position:new u(l.payload.position)}})}),a=await this.listen(o.DRAG_DROP,l=>{e({...l,payload:{type:"drop",paths:l.payload.paths,position:new u(l.payload.position)}})}),r=await this.listen(o.DRAG_LEAVE,l=>{e({...l,payload:{type:"leave"}})});return()=>{i(),a(),n(),r()}}}function ke(){const t=de();return new f(t.label,{skip:!0})}async function J(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new f(e,{skip:!0})))}class f{constructor(e,i={}){var n;this.label=e,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview_window",{options:{...i,parent:typeof i.parent=="string"?i.parent:(n=i.parent)===null||n===void 0?void 0:n.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async a=>this.emit("tauri://error",a))}static async getByLabel(e){var i;const n=(i=(await J()).find(a=>a.label===e))!==null&&i!==void 0?i:null;return n?new f(n.label,{skip:!0}):null}static getCurrent(){return ke()}static async getAll(){return J()}async listen(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:P(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,i){return this._handleTauriEvent(e,i)?()=>{const n=this.listeners[e];n.splice(n.indexOf(i),1)}:q(e,i,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}}Me(f,[x,F]);function Me(t,e){(Array.isArray(e)?e:[e]).forEach(i=>{Object.getOwnPropertyNames(i.prototype).forEach(n=>{var a;typeof t.prototype=="object"&&t.prototype&&n in t.prototype||Object.defineProperty(t.prototype,n,(a=Object.getOwnPropertyDescriptor(i.prototype,n))!==null&&a!==void 0?a:Object.create(null))})})}const D=new Map,Ce=async(t,e,i)=>{const n=i?.padding??20;if(i?.x!==void 0&&i?.y!==void 0)return{x:i.x,y:i.y};let a=1920,r=1080;try{const w=await Ie();w?.size&&(a=w.size.width,r=w.size.height)}catch(w){console.warn("Failed to get monitor info, using defaults:",w)}switch(i?.position??"right-bottom"){case"right-bottom":return{x:a-t-n,y:r-e-n};case"right-top":return{x:a-t-n,y:n};case"left-bottom":return{x:n,y:r-e-n};case"left-top":return{x:n,y:n};case"center":return{x:(a-t)/2,y:(r-e)/2};default:return{x:a-t-n,y:r-e-n}}},we=async t=>{const e=String(t.id),i=c.getState();if(i.isWindowActive(e)){console.log(`Notice window already open for message: ${e}`);return}const n=E(),a=`notice-${e}`,r=`${n.routePrefix}/${t.type}?id=${t.id}`,l=t.min_width||n.defaultWidth,w=t.min_height||n.defaultHeight,{x:m,y:v}=await Ce(l,w,t.windowPosition);try{const p=new f(a,{url:r,title:t.title,width:l,height:w,x:m,y:v,resizable:!0,decorations:!0,skipTaskbar:!1,alwaysOnTop:!0});D.set(e,p),i.addActiveWindow(e),p.once("tauri://destroyed",async()=>{D.delete(e),i.removeActiveWindow(e),await te(e),i.clearCurrent()}),console.log(`Created notice window: ${a}`)}catch(p){console.error("Failed to create notice window:",p),i.removeActiveWindow(e),i.clearCurrent()}},I=async t=>{const e=String(t),i=D.get(e);if(i)try{await i.close(),D.delete(e),console.log(`Closed notice window: ${e}`)}catch(n){console.error("Failed to close notice window:",n)}},he=async()=>{const t=Array.from(D.keys()).map(e=>I(e));await Promise.all(t)},ge=()=>{let t=null;c.subscribe(e=>{const i=e.currentMessage;i&&i!==t?(t=i,we(i)):i||(t=null)}),console.log("Notice window system initialized")},Le=()=>{const t=c(i=>i.currentMessage);return{closeNotice:h.useCallback(async()=>{t&&await I(t.id)},[t])}},Re=()=>{const t=c();return{hideNotice:h.useCallback(async i=>{await ie(i),await I(i),t.currentMessage?.id===i&&t.clearCurrent()},[t])}},Ee=()=>{const t=c(i=>i.clearOnLogout);return{hideAllNotices:h.useCallback(async()=>{await he(),await t()},[t])}},Te=()=>{const t=c(W.queueLength),e=c(W.currentMessage),i=c(W.isProcessing),n=c(W.queue);return{queueLength:t,currentMessage:e,isProcessing:i,queue:n}},qe=({children:t,onLoad:e,onClose:i})=>{const[n,a]=h.useState(null),[r,l]=h.useState(!0),[w,m]=h.useState(null);return h.useEffect(()=>{(async()=>{try{const B=new URLSearchParams(window.location.search).get("id");if(!B){m("No message ID provided"),l(!1);return}const k=await ne(B);if(!k){m("Message not found"),l(!1);return}a(k),l(!1),e&&e(k)}catch(p){console.error("Failed to load message:",p),m("Failed to load message"),l(!1)}})()},[e]),h.useEffect(()=>{if(!n||!i)return;const v=()=>{i(n)};return window.addEventListener("beforeunload",v),()=>{window.removeEventListener("beforeunload",v)}},[n,i]),r?z.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif"},children:"Loading..."}):w||!n?z.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",fontFamily:"system-ui, -apple-system, sans-serif",color:"#ef4444"},children:w||"Message not found"}):z.jsx(z.Fragment,{children:t(n)})},Fe=async()=>{T(),ge();const{initializeFromDatabase:t}=c.getState();await t(),console.log("Tauri Notice System initialized")};exports.NoticeLayout=qe;exports.clearPendingMessages=se;exports.closeAllNoticeWindows=he;exports.closeNoticeWindow=I;exports.createNoticeWindow=we;exports.getMessage=ne;exports.getNoticeConfig=E;exports.getPendingMessages=ee;exports.hasMessage=X;exports.initializeDatabase=T;exports.initializeNoticeSystem=Fe;exports.initializeNoticeWindowSystem=ge;exports.markAsHidden=ie;exports.markAsShown=te;exports.messageQueueSelectors=W;exports.saveMessage=K;exports.setNoticeConfig=fe;exports.useCloseNotice=Le;exports.useHideAllNotices=Ee;exports.useHideNotice=Re;exports.useMessageQueue=Te;exports.useMessageQueueStore=c;exports.useNoticeWindow=Ne;
2
2
  //# sourceMappingURL=index.cjs.map