diff --git a/config.json b/config.json index b888f803..463af7e9 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,7 @@ { "info": { "name": "CAIO", - "version": "2.2.13", + "version": "2.2.14", "author": "ipuppet", "module": false }, diff --git a/dist/CAIO.json b/dist/CAIO.json index 3d9ccbff..6ef90c6b 100644 --- a/dist/CAIO.json +++ b/dist/CAIO.json @@ -12,7 +12,7 @@ "type": "@flow.javascript", "parameters": { "script": { - "value": "(()=>{let t;var e=globalThis,i={},s={},n=e.parcelRequire94c2;null==n&&((n=function(t){if(t in i)return i[t].exports;if(t in s){var e=s[t];delete s[t];var n={id:t,exports:{}};return i[t]=n,e.call(n.exports,n,n.exports),n.exports}var a=Error(\"Cannot find module '\"+t+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}).register=function(t,e){s[t]=e},e.parcelRequire94c2=n);var a=n.register;switch(a(\"6olY1\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.ViewController,r=i.TabBarController,o=n(\"8Makm\").AppKernelBase,l=n(\"gYDdO\"),h=n(\"iuWEe\");class c extends o{constructor(){super(),this.query=$context.query,h(this)}}class d{static kernel=new c;static renderMainUI(){let t={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(s.isTaio||0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:t.setting.icon,title:t.setting.title,handler:()=>{s.push({title:t.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:t.actions.icon,title:t.actions.title,handler:()=>{this.kernel.actions.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new a),this.kernel.tabBarController=new r;let e=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:e.getPage(),actions:this.kernel.actions.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:t.clips,actions:t.actions,setting:t.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}}t.exports={run:()=>{l(d.kernel),d.renderMainUI()}}}),a(\"gxpqj\",function(t,e){var i=class{title;handler;constructor({title:t=$l10n(\"OK\"),disabled:e=!1,style:i=$alertActionType.default,handler:s=()=>{}}={}){this.title=t,this.disabled=e,this.style=i,this.handler=s}},s=class t{id=$text.uuid;title;message;actions;titleFont=$font(\"bold\",20);messageFont=$font(14);actionButtonFontSize=16;actionButtonHighlight=$color($rgba(0,0,0,.2),$rgba(255,255,255,.2));actionButtonHeight=35;actionButtonBoderWidth=.5;actionButtonBorderColor=$color(\"#C9C9C9\",\"#383838\");boxWidth=250;textVerticalMargin=20;textHorizontalMargin=50;constructor({title:t=\"\",message:e=\"\",actions:s=[]}={}){this.title=t,this.message=e,this.actions=s,0===this.actions.length&&this.actions.push(new i),this.titleSize=m.getContentSize(this.titleFont,this.title,this.boxWidth-2*this.textHorizontalMargin),this.messageSize=m.getContentSize(this.messageFont,this.message,this.boxWidth-2*this.textHorizontalMargin)}textView(){return{type:\"view\",views:[{type:\"label\",props:{lines:0,font:this.titleFont,text:this.title,color:$color(\"tint\"),align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.titleSize.height),t.top.equalTo(this.textVerticalMargin)}},{type:\"label\",props:{lines:0,font:this.messageFont,text:this.message,align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.messageSize.height),t.top.equalTo(e.prev.bottom)}}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin)}}}actionView(){let t=(t,e)=>{let i=t=>2===this.actions.length?t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth/2:t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth,s=async(s,n,a)=>{t.disabled||(s.bgcolor=$color(\"clear\"),i(n)&&(\"function\"==typeof t.handler&&await t.handler({index:e,title:t.title}),this.dismiss()))},n=$color(\"tint\"),a=$font(this.actionButtonFontSize);return t.disabled?n=$color(\"gray\"):t.style===$alertActionType.destructive?n=$color(\"red\"):t.style===$alertActionType.cancel&&(a=$font(\"bold\",this.actionButtonFontSize)),{type:\"label\",props:{lines:1,text:t.title,align:$align.center,font:a,color:n,borderWidth:this.actionButtonBoderWidth,borderColor:this.actionButtonBorderColor,bgcolor:$color(\"clear\")},events:{tapped:()=>{},touchesBegan:e=>{t.disabled||(e.bgcolor=this.actionButtonHighlight)},touchesEnded:s,touchesCancelled:s,touchesMoved:(e,s,n)=>{t.disabled||(i(s)?e.bgcolor=this.actionButtonHighlight:e.bgcolor=$color(\"clear\"))}},layout:(t,e)=>{2===this.actions.length?e.prev?(t.left.equalTo(e.prev.right).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).dividedBy(2).offset(this.actionButtonBoderWidth)):t.width.equalTo(e.super).dividedBy(2):(t.width.equalTo(e.super),e.prev&&t.top.equalTo(e.prev.bottom).offset(-this.actionButtonBoderWidth)),t.height.equalTo(this.actionButtonHeight)}}};return{type:\"view\",views:this.actions.map((e,i)=>t(e,i)),layout:(t,e)=>{t.left.equalTo(e.super).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).offset(2*this.actionButtonBoderWidth),t.bottom.equalTo(e.super),t.top.equalTo(e.prev.bottom)}}}getView(){let t={type:\"view\",props:{id:this.id+\"-box\",smoothCorners:!0,cornerRadius:20,bgcolor:$color(\"#FFFFFF\",\"#000000\")},views:[this.textView(),this.actionView()],layout:(t,e)=>{t.center.equalTo(e.super.safeArea);let i=this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin,s=this.actions.length>2?this.actions.length:1;i+=this.actionButtonHeight*s,i-=this.actionButtonBoderWidth*s;let n=this.boxWidth-2*this.actionButtonBoderWidth;t.size.equalTo($size(n,i))}};return{type:\"view\",props:{id:this.id,alpha:0,bgcolor:$rgba(0,0,0,.6)},views:[t],layout:$layout.fill}}present(){let t=$ui.create(this.getView());$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout($layout.fill),e.moveToFront(),$ui.animate({duration:.3,animation:()=>{e.alpha=1}})}dismiss(){let t=$(this.id);$ui.animate({duration:.3,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static fromJsbox(e){return new Promise((s,n)=>{new t({title:e.title,message:e.message,actions:e?.actions?.map(t=>(t.handler||(t.handler=t=>{s(t)}),new i(t)))}).present()})}},n=class{events={};setEvents(t){return Object.keys(t).forEach(e=>this.setEvent(e,t[e])),this}setEvent(t,e){return this.events[t]=e,this}appendEvent(t,e){let i=this.events[t];return\"function\"==typeof i?this.events[t]=(...t)=>{i(...t),e(...t)}:this.setEvent(t,e),this}callEvent(t,...e){\"function\"==typeof this.events[t]&&this.events[t](...e)}},a=class{viewController;constructor(){this.edges=10,this.iconSize=25}setViewController(t){this.viewController=t}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(t,e)=>{let i=t.object(e).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(t){$file.delete(t.path)}edit(t){let e=$file.read(t.path);if(e.info?.mimeType?.startsWith(\"image\"))g.quickLookImage(e,t.path.substring(t.path.lastIndexOf(\"/\")+1));else{let i=new g,s=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:s,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:e.string,insets:$insets(15,15,15,15)}}).addNavBar({title:t.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(s).text}),path:t.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(t=\"\"){return $file.list(t).map(e=>{let i=t+\"/\"+e,s=$file.isDirectory(i);return{info:{info:{path:i,file:e,isDirectory:s}},icon:{symbol:s?\"folder.fill\":\"doc\"},name:{text:e},size:{text:s?\"\":\"--\"}}}).sort((t,e)=>t.info.info.isDirectory!==e.info.info.isDirectory?t.info.info.isDirectory?-1:1:t.info.info.isDirectory===e.info.info.isDirectory?t.info.info.file.localeCompare(e.info.info.file):void 0)}async loadFileSize(t){return t.map((e,i)=>{let s=e.info.info;if(!s.isDirectory)try{t[i].size.text=m.bytesToSize($file.read(s.path).info.size)}catch(e){t[i].size.text=e}}),t}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.edges),t.size.equalTo(this.iconSize)}},{type:\"view\",views:[{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(this.edges)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(t,e)=>{t.height.left.equalTo(e.super),t.right.equalTo(e.prev.left).offset(-this.edges)}}],layout:(t,e)=>{t.height.right.equalTo(e.super),t.left.equalTo(e.prev.right).offset(this.edges)}}]}}#t(t){let e=t.lastIndexOf(\"/\"),i=t.substring(e<0?0:e+1),s=this.getListView(t),n=async()=>{let e=$file.absolutePath(t);0===(await $ui.alert({title:\"Path\",message:e,actions:[{title:$l10n(\"COPY\")},{title:$l10n(\"OK\")}]})).index&&($clipboard.text=e,$ui.toast($l10n(\"COPIED\")))};if(this.viewController){let t=new N;t.setView(s).navigationBarTitle(i),t.navigationBar.setLargeTitleDisplayMode(O.largeTitleDisplayModeNever),t.navigationBarItems.addRightButton({symbol:\"info.circle\",tapped:n}),this.viewController.push(t)}else m.push({title:i,views:[s],navButtons:[{symbol:\"info.circle\",handler:n}]})}getListView(t=\"\"){return{type:\"list\",props:{menu:this.menu,bgcolor:m.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(t,e)=>{let i=t.object(e).info.info;m.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',()=>{this.delete(i),t.delete(e)})}}]},layout:$layout.fill,events:{ready:e=>{let i=this.getFiles(t);e.data=i,this.loadFileSize(i).then(t=>{e.data=t})},pulled:async e=>{let i=this.getFiles(t);e.data=i,e.data=await this.loadFileSize(i),$delay(.5,()=>{e.endRefreshing()})},didSelect:(t,e,i)=>{let s=i.info.info;s.isDirectory?this.#t(s.path):this.edit(s)}}}}push(t=\"\"){this.#t(t)}},r=class t{basePath;constructor({basePath:t=\"storage\"}={}){this.basePath=t,this.#t(this.basePath)}static join(...t){let e=t.length,i=t[0];if(e<2)return i;for(let s=0;st&&(s=e.substring(t+1),e=e.substring(0,t+1))}return i&&this.#t(e),e+s}exists(t=\"\"){return t=this.filePath(t,!1),!!$file.exists(t)}write(t=\"\",e){return new Promise((i,s)=>{try{let n=this.writeSync(t,e);n?i(n):s(n)}catch(t){s(t)}})}writeSync(t=\"\",e){if(!e)throw new v(\"data\");return $file.write({data:e,path:this.filePath(t)})}read(t=\"\"){return new Promise((e,i)=>{try{let s=this.readSync(t);s?e(s):i()}catch(t){i(t)}})}readSync(t=\"\"){if(t=this.filePath(t),!$file.exists(t))throw new T(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}readAsJSON(t=\"\",e=null){try{let e=this.readSync(t)?.string;return JSON.parse(e)}catch{return e}}static readFromRoot(e=\"\"){return new Promise((i,s)=>{try{let n=t.readFromRootSync(e);n?i(n):s()}catch(t){s(t)}})}static readFromRootSync(t=\"\"){if(!t)throw new v(\"path\");if(!$file.exists(t))throw new T(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}static readFromRootAsJSON(e=\"\",i=null){try{let i=t.readFromRootSync(e)?.string;return JSON.parse(i)}catch{return i}}delete(t=\"\"){return $file.delete(this.filePath(t,!1))}copy(t,e){t=this.filePath(t),e=this.filePath(e),$file.copy({src:t,dst:e})}move(t,e){t=this.filePath(t),e=this.filePath(e),$file.move({src:t,dst:e})}},o=class t{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&(console.log(\"You are running EasyJsBox in debug mode.\"),$app.idleTimerDisabled=!0),l.init()}static isObject(t){return null!=t&&\"object\"==typeof t}static objectEqual(e,i){let s=Object.keys(e),n=Object.keys(i);if(s.length!==n.length)return!1;s.sort(),n.sort();for(let t=0;tt?i[t]:0,n=isNaN(Number(e))?e.charCodeAt():Number(e),r=s.length>t?s[t]:0,o=isNaN(Number(r))?r.charCodeAt():Number(r);if(no){a=1;break}}return a}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(t){this.isUseJsboxNav&&($ui.title=t),this.title=t}setNavButtons(t){this.navButtons=t}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(t={}){let e=$context.query;if(\"alertFromKeyboard\"===e.type){let t=JSON.parse($text.URLDecode(e.value));t.actions=[{title:$l10n(\"CANCEL\")}],$ui.alert(t);return}try{t.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},t.props),t.events||(t.events={});let e=t.events.layoutSubviews;t.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:m.statusBarOrientation,isHorizontal:m.isHorizontal}}),\"function\"==typeof e&&e()},$ui.render(t)}catch(t){this.print(t)}}KeyboardRender(t={}){t.id||(t.id=$text.uuid),$ui.render(),$delay(0,()=>{$ui.controller.view=$ui.create(t),$ui.controller.view.layout(t.layout)})}KeyboardRenderWithViewFunc(t){$ui.render(),$delay(0,()=>{$ui.controller.view=$ui.create({type:\"view\"}),$delay(0,async()=>{let e=await t();e.id||(e.id=$text.uuid),$ui.controller.view=$ui.create(e),$ui.controller.view.layout(e.layout)})})}async checkUpdate(){let e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;let i=e.data.match(/.*VERSION.+\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${i}`),t.versionCompare(i,\"1.4.5\")>0){let t=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(t.error)throw t.error;return t.data}return!1}},l=class{static l10n(t,e,i){if(\"string\"==typeof e){let t={};e.split(\";\").forEach(e=>{if(\"\"!==(e=e.trim())){let i=e.split(\"=\");t[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}}),e=t}let s=$app.strings;if(i)Object.assign(s[t],e);else for(let i in e)s[t][i]||(s[t][i]=e[i]);$app.strings=s}static set(t,e){this.l10n(t,e,!0)}static add(t,e){this.l10n(t,e,!1)}static init(){this.add(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE_PHOTO:\"从相册选择图片\",SELECT_IMAGE_ICLOUD:\"从 iCloud 选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"}),this.add(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE_PHOTO:\"Select From Photo\",SELECT_IMAGE_ICLOUD:\"Select From iCloud\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"}),this.add(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"}),this.add(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"}),this.add(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"}),this.add(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"})}},h=class t{static level={info:\"info\",warn:\"warn\",error:\"error\"};writer;fsLevels=[t.level.error];printToFile(t){this.fsLevels=t}setWriter(t,e){this.writer=i=>{t.exists(e)&&(i=(t.readSync(e)?.string??\"\")+i),t.writeSync(e,$data({string:i}))}}format(t,e){return`${new Date().toUTCString()} [${e.toUpperCase()}] ${t}\n`}log(t,e){this.writer&&this.fsLevels.includes(e)&&this.writer(this.format(t,e)),$app.isDebugging&&console[e](t)}info(e){this.log(e,t.level.info)}warn(e){this.log(e,t.level.warn)}error(e){this.log(e,t.level.error)}},c=class{rightButtons=[];leftButtons=[];#t={};hasbutton=!1;isPinTitleView=!1;setTitleView(t){return this.titleView=t,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(t){return this.fixedFooterView=t,this}setRightButtons(t){return t.forEach(t=>this.addRightButton(t)),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(t){return t.forEach(t=>this.addLeftButton(t)),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r}={}){let o=B.creat({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r,align:m.align.right});return this.rightButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r}={}){let o=B.creat({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r,align:m.align.left});return this.leftButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}getButton(t){return this.#t[t]}getButtons(){return Object.values(this.#t)}addPopButton(t,e,i){return t||(t=$l10n(\"BACK\")),this.popButtonView=e??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:m.linkColor,title:` ${t}`,titleColor:m.linkColor,font:$font(\"bold\",16)},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(B.style.edges),t.centerY.equalTo(e.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}},d=class{constructor(t){this.content=t}valueToJs(t){switch(t.tag){case\"dict\":return this.dictToJs(t);case\"true\":case\"false\":return\"true\"===t.tag;case\"integer\":return t.number;case\"key\":case\"string\":return t.string;case\"date\":return new Date(t.string);case\"array\":return this.arrayToJs(t);default:return t.node}}arrayToJs(t){let e=[];return t.children().forEach(t=>{e.push(this.valueToJs(t))}),e}dictToJs(t){let e=[],i=[];return t.children().forEach(t=>{\"key\"===t.tag?e.push(this.valueToJs(t)):i.push(this.valueToJs(t))}),Object.fromEntries(e.map((t,e)=>[t,i[e]]))}getObject(){if(!this.content)return!1;let t=$xml.parse({string:this.content,mode:\"xml\"});return this.valueToJs(t.rootElement.firstChild({xPath:\"//plist/dict\"}))}static get(t){return new this(t).getObject()}},u=class t{static method={get:\"GET\",post:\"POST\",put:\"PUT\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\",options:\"OPTIONS\"};static errorType={http:0,network:1};cacheContainerKey=$addin?.current?.name+\".request.cache\";#t;#e=!1;#i=!1;cacheLife=2592e6;#s=!1;timeout=5;logger;constructor(t){t instanceof h&&(this.logger=t)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#n(t){this.#s&&this.logger instanceof h&&this.logger.info(t)}logRequest(){return this.#s=!0,this}disableLogRequest(){this.#s=!1}getCacheKey(t){return $text.MD5(t)}getCache(t,e=null){return this.cache[t]??e}setCache(t,e){if(!e)return;let i=this.cache;i[t]=e,$cache.set(this.cacheContainerKey,i)}removeCache(t){let e=this.cache;delete e[t],$cache.set(this.cacheContainerKey,e)}clearCache(){$cache.remove(this.cacheContainerKey)}clearNSURLCache(){this.#t||(this.#t=$objc(\"NSURLCache\").$sharedURLCache()),this.#t.$removeAllCachedResponses()}enableCache(){return this.#e=!0,this}disableCache(){return this.#e=!1,this}ignoreCacheExp(){this.#i=!0}async request(e,i,s={},n={},a=this.cacheLife,r){let o,l=this.#e&&i===t.method.get;if(l){o=this.getCacheKey(e);let t=this.getCache(o);if(t&&(this.#i||t.exp>Date.now()))return this.#n(\"get data from cache: \"+e),t.data}this.#n(`sending request [${i}]: ${e}`);let h=await $http.request(Object.assign({header:n,url:e,method:i,body:i===t.method.get?null:s,timeout:this.timeout},r));if(h.error)throw new A({type:t.errorType.network,message:h.error.localizedDescription,code:h.error.code});if(h?.response?.statusCode>=400){let e=h.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new A({type:t.errorType.http,message:e,code:h.response.statusCode})}return l&&this.setCache(o,{exp:Date.now()+a,data:h}),h}},p=class t{static rowHeight=50;static edgeOffset=10;static iconSize=30;static iconDefaultColor=\"#00CC00\";setting;#t;#e;#i;title;#s={};#n;constructor({setting:t,key:e,title:i,icon:s,value:n=null}={}){this.setting=t,this.key=e,this.title=$l10n(i),this.icon=s,this.default=n}get method(){return this.setting.method}set key(t){return this.#e=t??$text.uuid,this.#t=void 0,this}get key(){return this.#e}get id(){return this.#t||(this.#t=`setting-${$text.uuid}-${this.key}`),this.#t}set icon(e){return e?Array.isArray(e)||(e=[e,t.iconDefaultColor]):e=[\"square.grid.2x2.fill\",t.iconDefaultColor],Array.isArray(e[0])||(e[0]=[e[0],e[0]]),e[1]?Array.isArray(e[1])||(e[1]=[e[1],e[1]]):e[1]=[t.iconDefaultColor,t.iconDefaultColor],this.#i=e,this}get icon(){return this.#i}get options(){return this.#s}set options(t){return this.#s=t??{},this}set(t){return\"function\"==typeof this.#n&&this.#n(t),this.setting.set(this.key,t)}onSet(t){return this.#n=t,this}get(t=this.default){return this.setting.getOriginal(this.key,t)}evalValues(t,e=[]){return\"string\"==typeof t?t.startsWith(\"this.method\")?Function(\"method\",`return ${t.replace(\"this.\",\"\")}()`)(this.method):Function(`return {${t}}`)():\"function\"==typeof t?t():t??e}createLineLabel(){return{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(this.icon[1][0],this.icon[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:Object.assign({tintColor:$color(\"white\")},this.icon[0][0].startsWith(\"icon_\")?{icon:$icon(this.icon[0][0].slice(5,this.icon[0][0].indexOf(\".\")>0?this.icon[0][0].indexOf(\".\"):this.icon[0][0].length),$color(\"#ffffff\"))}:{image:$image(this.icon[0][0],this.icon[0][1])}),layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(20)}}],layout:(e,i)=>{e.centerY.equalTo(i.super),e.size.equalTo(t.iconSize),e.left.inset(t.edgeOffset)}},{type:\"label\",props:{text:this.title,lines:1,align:$align.left},layout:(e,i)=>{e.centerY.equalTo(i.super),e.height.equalTo(i.super),e.left.equalTo(i.prev.right).offset(t.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(t,e)=>{t.height.centerY.equalTo(e.super),t.left.inset(0)}}}getView(){}create(){return this.getView(this.options)}},g=class t{#t=()=>{};#e=()=>{};style=t.UIModalPresentationStyle.PageSheet;#i=!1;#s;#n;#a;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){this.initNavBar(),$define({type:\"SheetViewController: UIViewController\",events:{\"viewWillDisappear:\":t=>{\"function\"==typeof this.#n&&this.#n(t)},\"viewDidDisappear:\":t=>{\"function\"==typeof this.#a&&this.#a(t)}}}),this.sheetVC=$objc(\"SheetViewController\").$new();let t=this.sheetVC.$view();return t.$addSubview($ui.create({type:\"view\"})),this.sheetVC.$setModalPresentationStyle(this.style),this.sheetVC.$setModalInPresentation(this.#i),this.#t=()=>{t.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",this.sheetVC,!0,null)},this.#e=()=>this.sheetVC.invoke(\"dismissViewControllerAnimated:completion:\",!0,null),this}initNavBar(){if(!this.#s)return;let{title:e=\"\",popButton:i={title:$l10n(\"CLOSE\")},rightButtons:s=[]}=this.#s;if(void 0===this.view)throw new I;this.navigationView=new N;let n=this.navigationView.navigationBar;n.setLargeTitleDisplayMode(O.largeTitleDisplayModeNever),n.navigationBarLargeTitleHeight-=n.navigationBarNormalHeight,n.navigationBarNormalHeight=m.PageSheetNavigationBarNormalHeight,n.navigationBarLargeTitleHeight+=n.navigationBarNormalHeight,this.style===t.UIModalPresentationStyle.FullScreen||this.style===t.UIModalPresentationStyle.OverFullScreen||this.style===t.UIModalPresentationStyle.BlurOverFullScreen?n.setTopSafeArea():n.removeTopSafeArea(),i.events=Object.assign({tapped:async()=>{\"function\"==typeof i.tapped&&await i.tapped(),this.dismiss()}},i.events??{}),this.navigationView.navigationBarItems.addLeftButton(i).setRightButtons(s),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor)}preventDismiss(){return this.#i=!0,this}setStyle(t){return this.style=t,this}setView(t={}){if(\"object\"!=typeof t)throw new te(\"view\",\"object\");return this.view=t,this}addNavBar(t){return this.#s=t,this}present(){this.#t()}dismiss(){this.#e()}willDismiss(t){return this.#n=t,this}didDismiss(t){return this.#a=t,this}static quickLookImage(e,i=$l10n(\"PREVIEW\")){new t().setView({type:\"view\",views:[{type:\"scroll\",props:{zoomEnabled:!0,maxZoomScale:3},layout:$layout.fill,views:[{type:\"image\",props:{data:e},layout:$layout.fill}]}],layout:$layout.fill}).addNavBar({title:i,rightButtons:[{symbol:\"square.and.arrow.up\",tapped:()=>$share.sheet(e)}]}).init().present()}},y=class{#t={};addTask(t,e=0){let i=$text.uuid;return this.#t[i]=$delay(e,async()=>{await t(),delete this.#t[i]}),i}cancelTask(t){this.#t[t].cancel()}clearTasks(){Object.values(this.#t).forEach(t=>t.cancel())}},f=class t{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;static defaultFont=$font(\"default\",26);width=Math.min(.6*m.windowSize.width,260);labelWidth=this.width-2*t.edges;id=$text.uuid;#t=\"\";font=t.defaultFont;type=t.type.info;labelLines=2;constructor(e,i=t.type.info,s=2,n=t.defaultFont){this.type=i,this.message=e,this.labelLines=s,this.font=n}get message(){return this.#t}set message(e){this.#t=e,this.fontHeight=m.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?t.labelTopMargin+t.iconSize:0)+this.fontHeight+2*t.edges}get hasIcon(){return void 0!==this.type}get blurBox(){let e=m.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,i)=>{e.top.inset(t.edges),e.size.equalTo(t.iconSize),e.centerX.equalTo(i.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,i)=>{e.bottom.equalTo(i.supper).offset(-t.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(i.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){let t=$ui.create(this.blurBox);$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout((t,e)=>{t.center.equalTo(e.super),t.size.equalTo($size(this.width,this.height))}),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){let t=$(this.id);t&&$ui.animate({duration:.2,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static toast({message:e,type:i=t.type.info,show:s=!0,displayTime:n=2,labelLines:a=2,font:r=t.defaultFont}){let o=new t(e,i,a,r);return s&&(o.show(),$delay(n,()=>{o.remove()})),o}static info(e,i={}){return t.toast(Object.assign({message:e,type:t.type.info},i))}static success(e,i={}){return t.toast(Object.assign({message:e,type:t.type.success},i))}static warning(e,i={}){return t.toast(Object.assign({message:e,type:t.type.warning},i))}static error(e,i={}){return t.toast(Object.assign({message:e,type:t.type.error},i))}},m=class t{static #t=$objc(\"UIApplication\").$sharedApplication();static #e=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){t.#e.$notificationOccurred(0)}static feedbackError(){t.#e.$notificationOccurred(2)}static isTaio=$app.info.bundleID.includes(\"taio\");static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+t.NavigationBarNormalHeight;static PageSheetNavigationBarNormalHeight=56;static get isSplitScreenMode(){return t.isLargeScreen&&$device.info.screen.width!==t.windowSize.width}static get topSafeAreaInsets(){return t.isTaio?0:t.#t?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return t.#t.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=t.#t.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===t.statusBarOrientation||4===t.statusBarOrientation}static loading(){let e=$ui.create(t.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(t,e)=>{t.size.equalTo(e.prev),t.center.equalTo(e.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout((e,i)=>{e.center.equalTo(i.super);let s=Math.min(.6*Math.min(t.windowSize.width,t.windowSize.height),260);e.size.equalTo($size(s,s))}),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return t.scrollViewList.indexOf(e)>-1?t.scrollViewBackgroundColor:t.primaryViewBackgroundColor}static separatorLine(e={},i=t.align.bottom){return{type:\"canvas\",props:e,layout:(e,s)=>{void 0===s.prev?e.top.equalTo(s.super):i===t.align.bottom?e.top.equalTo(s.prev.bottom):e.top.equalTo(s.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(t={},e=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},t),views:e,layout:i}}static getContentSize(e,i=\"A\",s=t.windowSize.width,n){let a={text:i,width:s,font:e};return void 0!==n&&(a.lineSpacing=n),$text.sizeThatFits(a)}static getSymbolSize(t,e){let i=(t=\"string\"==typeof t?$image(t):t).size.width/t.size.height;return t.size.width>t.size.height?$size(e,e/i):$size(e*i,e)}static push({views:t,statusBarStyle:e=0,title:i=\"\",navButtons:s=[{title:\"\"}],bgcolor:n=t[0]?.props?.bgcolor??\"primarySurface\",titleView:a,disappeared:r}={}){let o={statusBarStyle:e,navButtons:s,title:i,bgcolor:\"string\"==typeof n?$color(n):n};a&&(o.titleView=a),$ui.push({props:o,events:{disappeared:()=>{void 0!==r&&r()}},views:[{type:\"view\",views:t,layout:(t,e)=>{t.top.equalTo(e.super.safeArea),t.bottom.equalTo(e.super),t.left.right.equalTo(e.super.safeArea)}}]})}static compressImage(t,e=921600){let i=$imagekit.info(t);if(i.height*i.width>e){let s=e/(i.height*i.width);t=$imagekit.scaleBy(t,s)}return t}static deleteConfirm(t,e){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:t,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{e()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(t){if(0===t)return\"0 B\";let e=Math.floor(Math.log(t)/Math.log(1024));return(t/Math.pow(1024,e)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][e]}},w=class{#t;text=\"\";interval;fullScreen=!1;#e=()=>{};constructor(){this.#t=$text.uuid}updateText(t){$(this.#t).text=t}setLoop(t){if(\"function\"!=typeof t)throw\"loop must be a function\";this.#e=t}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(t,e)=>{t.centerY.equalTo(e.super).offset(-15),t.width.equalTo(e.super)}},{type:\"label\",props:{id:this.#t,align:$align.center,text:\"\"},layout:(t,e)=>{t.top.equalTo(e.prev.bottom).offset(10),t.left.right.equalTo(e.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval(()=>{this.#e()},100)}}})}},b=class t{id=$text.uuid;type;props;views;events;layout;#t=void 0;#e=null;constructor({type:t=\"view\",props:e={},views:i=[],events:s={},layout:n=$layout.fill}={}){this.type=t,this.props=e,this.views=i,this.events=s,this.layout=n,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(t){return new this(t)}static createFromViews(t){return new this({views:t})}get scrollableView(){return this.scrollable?this.#e:null}set scrollableView(t){this.#e=t}get scrollable(){if(void 0===this.#t){if(this.#t=!1,m.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#t=!0;else if(this.views.length>0){let e=i=>{if(!this.#t&&i?.length>0)for(let s=0;s-1){typeof i[s]!==t&&(i[s]=t.create(i[s])),this.scrollableView=i[s],this.#t=!0;return}else e(i[s].views)};e(this.views)}}return this.#t}set scrollable(t){throw Error(\"[scrollable] is readonly prop.\")}setProps(t){return Object.keys(t).forEach(e=>this.setProp(e,t[e])),this}setProp(t,e){return\"id\"===t&&(this.id=e),this.props[t]=e,this}setViews(t){return this.views=t,this.#t=void 0,this}setEvents(t){return Object.keys(t).forEach(e=>this.setEvent(e,t[e])),this}setEvent(t,e){return this.events[t]=e,this}eventMiddleware(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&e(i,...t)},this}assignEvent(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&i(...t),e(...t)},this}setLayout(t){return this.layout=t,this}getView(){return this}get definition(){return this.getView()}},v=class extends Error{constructor(t){super(`Parameter [${t}] is required.`),this.name=\"FileStorageParameterError\"}},T=class extends Error{constructor(t){super(`File not found: ${t}`),this.name=\"FileStorageFileNotFoundError\"}},A=class extends Error{constructor({message:t,code:e,type:i}={}){super(t),this.name=\"RequestError\",this.code=e,this.type=i}},E=class extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}},S=class extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}},I=class extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetViewUndefinedError\"}},x=class extends Error{constructor(t,e){super(`The type of the parameter '${t}' must be '${e}'`),this.name=\"ValidationError\"}},C=class extends b{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",m.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height)},this.views=[b.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},k=class extends b{titleStyle={font:$font(\"bold\",21),height:30};#t;#e;templateIdByIndex(t){return this.props.template.views[t]?.props?.id===void 0&&(void 0===this.props.template.views[t].props&&(this.props.template.views[t].props={}),this.props.template.views[t].props.id=$text.uuid),this.props.template.views[t].props.id}get templateHiddenStatus(){if(!this.#e){this.#e={};for(let t=0;t{t.items=t.items.filter(t=>t?.__title?.hidden===!0),e.push(t)}),e}set data(t){this.props.data=this.rebuildData(t),$(this.id).data=this.props.data}#i(t){let e={...this.hiddenViews};return Object.assign(e,{__templateProps:{hidden:!0},__title:{hidden:!1,text:t,info:{title:!0}}}),e}rebuildData(t=[]){return t.map(t=>(t.items=t.items.map(t=>(Object.keys(t).forEach(e=>{t[e].hidden=this.templateHiddenStatus[e]??!1}),Object.keys(this.templateHiddenStatus).forEach(e=>{t[e]||(t[e]={}),t[e].hidden=this.templateHiddenStatus[e]}),t.__templateProps={hidden:!1},t.__title={hidden:!0},t)),t.title&&t.items.unshift(this.#i(t.title)),t))}rebuildTemplate(){let t={};void 0!==this.props.template.props&&(void 0!==this.props.template.props.cornerRadius&&(this.props.template.props.clipsToBounds=!1),t=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1}));let e=[{type:\"view\",props:t,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(t,e)=>{t.top.inset(-(3*(this.titleStyle.height/4))),t.height.equalTo(this.titleStyle.height),t.width.equalTo(e.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=e}insert(t,e=!0){return t.indexPath=this.indexPath(t.indexPath,e),$(this.id).insert(t)}delete(t,e=!0){return t=this.indexPath(t,e),$(this.id).delete(t)}object(t,e=!0){return t=this.indexPath(t,e),$(this.id).object(t)}cell(t,e=!0){return t=this.indexPath(t,e),$(this.id).cell(t)}indexPath(t,e){let i=e?1:0;return t=\"number\"==typeof t?$indexPath(0,t+i):$indexPath(t.section,t.row+i)}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",(t,e)=>{if(t.object(e)?.__title?.info?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);let i=this.props.columns??2,s=this.props.spacing??15;return $size(this.props.itemWidth??this.props.itemSize?.width??(t.super.frame.width-s*(i+1))/i,this.props.itemHeight??this.props.itemSize?.height??100)}),this}},D=class extends b{controller={};setController(t){return this.controller=t,this}},B=class t extends b{static #t;edges=15;buttonEdges=this.edges/2;iconSize=24;fontSize=17;color=m.textColor;title;#e;#i;align=m.align.right;get symbol(){return\"string\"==typeof this.#e?\"icon\"===this.#i?$icon(this.#e,this.color):$image(this.#e):this.#e}set symbol(t){\"string\"==typeof this.#e?isNaN(t)?this.#i=\"image\":this.#i=\"icon\":\"[object BBFileIcon]\"===String(t)?this.#i=\"icon\":this.#i=\"image\",this.#e=t}get width(){return this.title?Math.ceil($text.sizeThatFits({text:this.title,width:m.windowSize.width,font:$font(this.fontSize)}).width)+this.edges:this.iconSize+this.edges}static get style(){return void 0===this.#t&&(this.#t=new t),this.#t}setEdges(t){return this.edges=t,this}setFontSize(t){return this.fontSize=t,$(this.id)&&($(this.id).font=$font(this.fontSize)),this}setColor(t=m.textColor){return this.color=t,$(this.id)&&($(this.id).titleColor=this.color,$(`icon-button-${this.id}`).titleColor=this.color,$(`icon-checkmark-${this.id}`).titleColor=this.color),this}setTitle(t){return this.title=t,$(this.id)&&($(this.id).title=this.title),this}setSymbol(t){return this.symbol=t,$(`icon-button-${this.id}`)&&(\"icon\"===this.#i?$(`icon-button-${this.id}`).icon=this.symbol:$(`icon-button-${this.id}`).image=this.symbol),this}setMenu(t){return this.menu=t,this}setAlign(t){return this.align=t,this}setLoading(t){t?($(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1):($(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0)}#s(){let t=$(`icon-button-${this.id}`),e=$(`icon-checkmark-${this.id}`);t.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{e.alpha=1},completion:()=>{$delay(.3,()=>$ui.animate({duration:.6,animation:()=>{e.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{t.alpha=1},completion:()=>{t.alpha=1}})}}))}})}hide(){$(this.id+\"-container\").hidden=!0}show(){$(this.id+\"-container\").hidden=!1}getView(){let t=this.events.tapped;return this.events.tapped=e=>{t&&t({start:()=>this.setLoading(!0),done:()=>this.#s(),cancel:()=>this.setLoading(!1)},e)},{type:\"view\",props:{id:this.id+\"-container\",info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},this.symbol?\"icon\"===this.#i?{icon:this.symbol}:{image:this.symbol}:{}),layout:(t,e)=>{this.symbol&&\"image\"===this.#i&&t.size.equalTo(m.getSymbolSize(this.symbol,this.iconSize)),t.center.equalTo(e.super)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(m.getSymbolSize(\"checkmark\",this.iconSize))}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(t,e)=>{if(t.size.equalTo($size(this.width,m.NavigationBarNormalHeight)),t.centerY.equalTo(e.super),e.prev&&e.prev?.info?.align===this.align)this.align===m.align.right?t.right.equalTo(e.prev.left).offset(-this.buttonEdges):t.left.equalTo(e.prev.right).offset(this.buttonEdges);else{let e=this.edges/2;this.align===m.align.right?t.right.inset(e):t.left.inset(e)}}}}static creat({id:e,symbol:i,title:s,tapped:n,menu:a,events:r,color:o,align:l=m.align.right}={}){let h=new t;return h.setEvents(Object.assign({tapped:n},r)).setAlign(l).setSymbol(i).setTitle(s).setColor(o).setMenu(a),e&&h.setProp(\"id\",e),h}},O=class t extends b{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=t.largeTitleDisplayModeAutomatic;fontFamily=\"bold\";largeTitleFontSize=34;largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.fontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=0;navigationBarNormalHeight=m.NavigationBarNormalHeight;navigationBarLargeTitleHeight=m.NavigationBarLargeTitleHeight;setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(t){return this.largeTitleDisplayMode=t,this}setBackgroundColor(t){return this.backgroundColor=t,this}setTitle(t){return this.title=t,this}setPrefersLargeTitles(t){return this.prefersLargeTitles=t,this}setContentViewHeightOffset(t){return this.contentViewHeightOffset=t,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==t.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:m.textColor,align:$align.left,font:$font(this.fontFamily,this.largeTitleFontSize),line:1},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(15),t.height.equalTo(this.largeTitleFontHeight),t.top.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){let e=(t,e)=>{let i=(t,i)=>{t.top.equalTo(i.super.safeAreaTop),t.bottom.equalTo(i.super.safeAreaTop).offset(this.navigationBarNormalHeight),e===m.align.left?t.left.equalTo(i.super.safeArea):t.right.equalTo(i.super.safeArea)};if(t&&!Array.isArray(t))return{type:\"view\",views:[t],layout:i};let s=0,n=[];t.forEach(t=>{s+=t.width,n.push(t.definition)});let a=t[0]?.edges??0;return s+=t.length>=2?2*a:a,t.length>0?{type:\"view\",views:n,info:{width:s},layout:(t,e)=>{i(t,e),t.width.equalTo(s)}}:{type:\"view\",layout:t=>t.size.equalTo(0)}},i=e(this.navigationBarItems.popButtonView??this.navigationBarItems.leftButtons,m.align.left),s=e(this.navigationBarItems.rightButtons,m.align.right),n=this.prefersLargeTitles,a=!this.prefersLargeTitles||this.largeTitleDisplayMode===t.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:n,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:m.blurBox({hidden:n,id:this.id+\"-background\"}),m.separatorLine({id:this.id+\"-underline\",alpha:n?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:t=>{t.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},i,s,{type:\"view\",views:[{type:\"label\",props:{id:this.id+\"-small-title\",alpha:a?1:0,text:this.title,font:$font(this.fontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:m.textColor},layout:(t,e)=>{t.edges.equalTo(e.super.safeArea);let n=m.getContentSize($font(this.fontFamily,this.navigationBarTitleFontSize),e.text).width,a=Math.max(i.info?.width??0,s.info?.width??0);m.windowSize.width-2*a>n&&t.centerX.equalTo(e.super.super)}}],layout:(t,e)=>{t.top.bottom.equalTo(e.super.safeArea),t.left.equalTo(e.prev.prev.right),t.right.equalTo(e.prev.left)}}]}}},R=class t extends n{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=O.largeTitleDisplayModeNever)}toLargeTitle(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=O.largeTitleDisplayModeAlways)}#t(e){let i=e===t.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=i?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=i?1:0}})}#e(e){if(this.selector.largeTitleView.updateLayout((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)}),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#t(t.largeTitleViewSmallMode):this.#t(t.largeTitleViewLargeMode);else{this.#t(t.largeTitleViewLargeMode);let i=this.navigationBar.largeTitleFontSize-.04*e;i>40&&(i=40),this.selector.largeTitleView.font=$font(this.navigationBar.fontFamily,i)}}#i(t){let e=this.navigationBar.largeTitleDisplayMode===O.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(t>e){this.selector.backgroundView.hidden=!1;let s=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(t-e)/3>=1?s():$ui.animate({duration:.2,animation:()=>{s()}})}else this.selector.largeTitleMaskView.alpha=t>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(t){if(!this.navigationBar.prefersLargeTitles)return;let e=this.navigationBar.largeTitleDisplayMode;if(e!==O.largeTitleDisplayModeAlways){if(this.updateSelector(),e===O.largeTitleDisplayModeAutomatic){if(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(t),t>0)){let e=this.navigationBar.navigationBarItems?.titleView?.height??0;(t-=e)<0&&(t=0)}this.#e(t),this.#i(t)}else e===O.largeTitleDisplayModeNever&&this.#i(t)}}didEndDragging(t,e,i,s){if(!this.navigationBar.prefersLargeTitles)return;let n=this.navigationBar.largeTitleDisplayMode;if(n!==O.largeTitleDisplayModeAlways&&(this.updateSelector(),n===O.largeTitleDisplayModeAutomatic)){let n=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(t,e,i,s),n=this.navigationBar.navigationBarItems?.titleView?.height??0,t-=n),t>=0&&t<=this.navigationBar.largeTitleFontHeight&&i($point(0,t>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+n-s:n-s))}}},L=class extends x{constructor(t,e){super(t,e),this.name=\"NavigationViewTypeError\"}},N=class extends n{page;navigationController=new R;navigationBar=new O;navigationBarItems=new c;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(t){return this.navigationBar.setTitle(t),this}setView(t){if(\"object\"!=typeof t)throw new L(\"view\",\"object\");return this.view=b.create(t),this}getTopOffset(){if(!(this.view instanceof b))throw new L(\"view\",\"View\");let t=this.view.scrollableView,e=$app.isDebugging?0:m.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===O.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight,s=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(s+=this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===t.props.associateWithNavigationBar){let t=s-this.navigationBar.contentViewHeightOffset;return(!m.isHorizontal||m.isLargeScreen)&&this.navigationBar.topSafeArea&&(t+=e),t}return t.props.stickyHeader&&(s-=i,s+=this.navigationBar.largeTitleFontHeight),s}getBottomOffset(){return this.navigationBarItems.fixedFooterView?.height??0}#t(){if(!(this.view instanceof b))throw new L(\"view\",\"View\");let t=this.view.scrollableView,e=$app.isDebugging?0:m.topSafeAreaInsets,i=this.getTopOffset();if(!this.view.scrollable||!1===t.props.associateWithNavigationBar){this.view.layout=(t,e)=>{t.left.right.equalTo(e.super.safeArea),t.bottom.equalTo(e.super),t.top.equalTo(i)};return}let s=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(t.props.indicatorInsets){let e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top+this.navigationBar.navigationBarNormalHeight+s,e.left,e.bottom+this.getBottomOffset(),e.right)}else t.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+s,0,this.navigationBarItems.fixedFooterView?.height??0,0);if(t.props.contentInset){let e=t.props.contentInset;t.props.contentInset=$insets(e.top+i+s,e.left,e.bottom+this.getBottomOffset(),e.right)}else t.props.contentInset=$insets(i+s,0,this.navigationBarItems.fixedFooterView?.height??0,0);t.props.contentOffset=$point(0,-i),t.layout=(e,i)=>{t.props.stickyHeader?e.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):e.top.equalTo(i.super),e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super)},t.assignEvent(\"didScroll\",s=>{let n=s.contentOffset.y;(!m.isHorizontal||m.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(n+=e),n+=i,this.navigationController.didScroll(n)}).assignEvent(\"didEndDragging\",(s,n)=>{let a=s.contentOffset.y,r=0;(!m.isHorizontal||m.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(a+=e,r=e),a+=i,r+=i,this.navigationController.didEndDragging(a,n,(...t)=>s.scrollToOffset(...t),r)}).assignEvent(\"didEndDecelerating\",(...e)=>{e[0].tracking||t.events?.didEndDragging(...e)})}#e(){if(this.navigationBar.prefersLargeTitles){this.#t();let t={};if(this.navigationBarItems.titleView){let e=this.navigationBar.largeTitleDisplayMode===O.largeTitleDisplayModeNever?1:0;t=b.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:e,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:m.blurBox({alpha:e,id:this.navigationBar.id+\"-title-view-background\"}),m.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:e}),this.navigationBarItems.titleView.definition],layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.width.equalTo(e.super),t.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=ta.createFromViews([this.view,this.navigationBar.getLargeTitleView(),t,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=ta.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",m.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#e(),this.page}},P=class extends D{height=35;topOffset=15;bottomOffset=10;horizontalOffset=15;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;cancelButtonFont=$font(16);constructor(t){super(t),this.setController(new V),this.controller.setSearchBar(this)}get cancelButtonWidth(){return m.getContentSize(this.cancelButtonFont,$l10n(\"CANCEL\")).width}setEvent(t,e){return this.inputEvents[t]=e,this}setPlaceholder(t){return this.placeholder=t,this}setKbType(t){return this.kbType=t,this}setKeyboardView(t){return this.keyboardView=t,this}setAccessoryView(t){return this.accessoryView=t,this}onBeginEditingAnimate(){$ui.animate({duration:.3,animation:()=>{let t=this.cancelButtonWidth;$(this.id+\"-cancel-button\").updateLayout((e,i)=>{e.left.equalTo(i.super.right).offset(-t)}),$(this.id+\"-cancel-button\").alpha=1,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout(e=>{e.right.inset(t+this.horizontalOffset/2)}),$(this.id+\"-input\").relayout()}})}onEndEditingAnimate(){$ui.animate({duration:.3,animation:()=>{$(this.id+\"-cancel-button\").updateLayout((t,e)=>{t.left.equalTo(e.super.right)}),$(this.id+\"-cancel-button\").alpha=0,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout($layout.fill),$(this.id+\"-input\").relayout()}})}cancel(){$(this.id+\"-input\").blur(),$(this.id+\"-input\").text=\"\",this.onEndEditingAnimate(),this.controller.callEvent(\"onCancel\")}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"#EEF1F1\",\"#212121\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({didBeginEditing:t=>{this.onBeginEditingAnimate(),this.controller.callEvent(\"onBeginEditing\",t.text)},didEndEditing:t=>{this.controller.callEvent(\"onEndEditing\",t.text)},changed:t=>this.controller.callEvent(\"onChange\",t.text),returned:t=>this.controller.callEvent(\"onReturn\",t.text)},this.inputEvents)},{type:\"button\",props:{id:this.id+\"-cancel-button\",title:$l10n(\"CANCEL\"),font:this.cancelButtonFont,titleColor:$color(\"tintColor\"),bgcolor:$color(\"clear\"),alpha:0,hidden:!1},events:{tapped:()=>this.cancel()},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(this.cancelButtonWidth),t.left.equalTo(e.super.right)}}],this.layout=(t,e)=>{t.height.equalTo(this.height),t.top.equalTo(e.super.safeArea).offset(this.topOffset),t.left.equalTo(e.super.safeArea).offset(this.horizontalOffset),t.right.equalTo(e.super.safeArea).offset(-this.horizontalOffset)},this}},V=class extends n{setSearchBar(t){return this.searchBar=t,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout(t=>{t.height.equalTo(0)})}show(){this.updateSelector(),this.selector.inputBox.updateLayout(t=>{t.height.equalTo(this.searchBar.height)})}didScroll(t){this.updateSelector();let e=this.searchBar.height-t;if(e=e>0?e>this.searchBar.height?this.searchBar.height:e:0,this.selector.inputBox.updateLayout(t=>{t.height.equalTo(e)}),t>0){let e=(this.searchBar.height/2-5-t)/10;this.selector.input.alpha=e}else this.selector.input.alpha=1}didEndDragging(t,e,i){this.updateSelector(),t>=0&&t<=this.searchBar.height&&i($point(0,t>=this.searchBar.height/2?this.searchBar.height:0))}},_=class extends n{#t=[];#e(t){t.callEvent(\"onPop\"),this.callEvent(\"onPop\",t),this.#t.pop()}push(t){let e=this.#t[this.#t.length-1];t.navigationBarItems.addPopButton(e?.navigationBar.title),this.#t.push(t),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{disappeared:()=>{this.#e(t)}},views:[t.getPage().definition],layout:$layout.fill})}},q=class extends p{get isArray(){return Array.isArray(this.default)}async tapped(){let t=this.isArray?this.default[1]:this.default;0===(await $ui.alert({title:this.title,message:t,actions:[{title:$l10n(\"COPY\")},{title:$l10n(\"OK\")}]})).index&&($clipboard.text=t,$ui.toast($l10n(\"COPIED\")))}getView(){return{type:\"view\",props:{selectable:!0,info:{key:this.key}},views:[this.createLineLabel(),{type:\"label\",props:{text:this.isArray?this.default[0]:this.default,align:$align.right,textColor:$color(\"darkGray\")},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(p.edgeOffset),t.width.equalTo(180)}}],layout:$layout.fill}}},M=class extends p{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"switch\",props:{on:this.get(),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(t.on)}catch(e){throw t.on=!t.on,e}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(p.edgeOffset)}}],layout:$layout.fill}}},F=class extends p{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{let e=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.id}-string`,align:$align.left,text:this.get()},layout:t=>{t.left.right.inset(10),t.top.inset(20),t.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:t=>{t.right.inset(10),t.bottom.inset(25),t.size.equalTo(30)},events:{tapped:()=>{this.set($(`${this.id}-string`).text),e.dismiss()}}}]})}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(0),t.size.equalTo(50)}}],layout:$layout.fill}}},U=class extends p{with({min:t,max:e}={}){return this.options={min:t,max:e},this}getView({min:t,max:e}={}){let i=`${this.id}-label`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"label\",props:{id:i,text:this.get(),align:$align.left},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(120)}},{type:\"stepper\",props:{min:t,max:e,value:this.get()},events:{changed:t=>{$(i).text=t.value;try{this.set(t.value)}catch(t){throw $(i).text=this.get(),t}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(p.edgeOffset)}}],layout:$layout.fill}}},H=class extends p{rightSymbol=\"chevron.right\";buttonId=`${this.id}-button`;start(){$(this.buttonId).alpha=0,$(`${this.buttonId}-spinner`).alpha=1}cancel(){$(this.buttonId).alpha=1,$(`${this.buttonId}-spinner`).alpha=0}done(){$(`${this.buttonId}-spinner`).alpha=0;let t=$(this.buttonId);t.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>t.alpha=1,completion:()=>{$ui.animate({duration:.4,animation:()=>t.alpha=0,completion:()=>{t.symbol=this.rightSymbol,$ui.animate({duration:.4,animation:()=>t.alpha=1})}})}})}with({script:t}={}){return this.options={script:t},this}async tapped(){let t={start:()=>this.start(),cancel:()=>this.cancel(),done:()=>this.done()},{script:e}=this.options;\"function\"==typeof e?await e(t):e.startsWith(\"this.method\")?await Function(\"method\",\"animate\",`return async()=>{await ${e.replace(\"this.\",\"\")}(animate)}`)(this.method,t)():await Function(\"animate\",`return async()=>{${e}}`)(t)()}getView(){return{type:\"view\",props:{id:this.id,selectable:!0,info:{key:this.key}},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{id:this.buttonId,symbol:\"chevron.right\",bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},events:{tapped:()=>this.tapped()},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(0),t.height.equalTo(e.super)}},{type:\"spinner\",props:{id:`${this.buttonId}-spinner`,loading:!0,alpha:0},layout:(t,e)=>{t.size.equalTo(15),t.centerY.equalTo(e.super),t.right.equalTo(e.prev)}}],layout:(t,e)=>{t.right.inset(p.edgeOffset),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},j=class extends p{with({items:t,values:e}={}){return Array.isArray(t)&&(t=t.map(t=>$l10n(t))),this.options={items:t,values:e},this}getView({items:t,values:e}={}){t=this.evalValues(t),e=this.evalValues(e);let i=t?.length>0&&e?.length===t?.length;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"tab\",props:{items:t??[],index:i?e.indexOf(this.get()):this.get(),dynamicWidth:!0},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.prev)},events:{changed:t=>{i?this.set(e[t.index]):this.set(t.index)}}}],layout:$layout.fill}}},z=class extends p{with({items:t,values:e,pullDown:i}={}){return Array.isArray(t)&&(t=t.map(t=>$l10n(t))),this.options={items:t,values:e,pullDown:i},this}getView({items:t,values:e,pullDown:i}={}){let s=`${this.id}-label`,n=this.evalValues(t),a=this.evalValues(e),r=n?.length>0&&a?.length===n?.length,o=(t,i)=>{if(r){let t=this.evalValues(e);this.set(t[i])}else this.set(i);$(s).title=t};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{menu:i?{pullDown:!0,asPrimary:!0,items:n.map((t,e)=>({title:t,handler:()=>o(t,e)}))}:void 0,title:r?n[a.indexOf(this.get())]:n[this.get()],titleColor:$color(\"secondaryText\"),bgcolor:$color(\"clear\"),id:s},events:{tapped:()=>{i||$ui.menu({items:this.evalValues(t),handler:o})}},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],layout:(t,e)=>{t.right.inset(p.edgeOffset),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},W=class extends p{get(t=null){let e=super.get(t);return e?\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha):t}getView(){let t=`${this.id}-color`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"view\",props:{id:t,bgcolor:this.get(),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(p.edgeOffset),t.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{let e=await $picker.color({color:this.get()});this.set(e.components),$(t).bgcolor=$rgba(e.components.red,e.components.green,e.components.blue,e.components.alpha)}},layout:(t,e)=>{t.right.inset(0),t.height.width.equalTo(e.super.height)}}],layout:(t,e)=>{t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},K=class extends p{with({mode:t=2}={}){return this.options={mode:t},this}getView({mode:t=2}={}){let e=e=>{let i=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),t){case 0:i=e.toLocaleTimeString();break;case 1:i=e.toLocaleDateString();break;case 2:i=e.toLocaleString()}return i};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"label\",props:{id:`${this.id}-label`,color:$color(\"secondaryText\"),text:this.get()?e(this.get()):\"None\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],events:{tapped:async()=>{let i=this.get(),s=await $picker.date({props:{mode:t,date:i||Date.now()}});this.set(s.getTime()),$(`${this.id}-label`).text=e(s)}},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},G=class extends p{with({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){return this.options={secure:t,kbType:e,saveFunc:i},this}getView({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){void 0===i&&(i=t=>this.set(t));let s=this.id+\"-input\";return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"input\",props:{id:s,type:e,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(),font:$font(16),secure:t,accessoryView:m.blurBox({height:44},[m.separatorLine({},m.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{$(s).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.left.inset(p.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{let t=$(s),e=this.get(\"\");t.text!==e&&(t.text=e),t.blur()}}}])},layout:(t,e)=>{t.left.equalTo(e.prev.get(\"label\").right).offset(p.edgeOffset),t.right.inset(p.edgeOffset),t.width.greaterThanOrEqualTo(50),t.height.equalTo(e.super),t.left.priority(10),t.width.priority(10)},events:{didBeginEditing:t=>{t.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:t=>{t.blur()},didEndEditing:async e=>{let s=this.get(\"\");i(e.text)||(e.text=s),t&&(e.secure=t)}}}],layout:$layout.fill}}},J=class extends p{getView(){return new G(this).getView({secure:!1,kbType:$kbType.decimal,saveFunc:t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)})}},Y=class extends p{with({bgcolor:t=\"#000000\"}={}){return this.options={bgcolor:t},this}getView({bgcolor:t=\"#000000\"}={}){let e=`${this.id}-image`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof t?$color(t):t,smoothCorners:!0},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:e,image:$image(this.get()),icon:$icon(this.get()?.slice(5,this.get().indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.right.equalTo(e.prev).offset(-5),t.centerY.equalTo(e.super),t.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){let t=await $ui.selectIcon();this.set(t),$(e).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else(1===i||2===i)&&$input.text({text:\"\",placeholder:t,handler:t=>{if(\"\"===t){$ui.toast($l10n(\"INVALID_VALUE\"));return}this.set(t),1===i?$(e).symbol=t:$(e).image=$image(t)}})}})}},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},X=class extends p{with({view:t,navButtons:e=[]}={}){return this.options={view:t,navButtons:e},this}tapped(){let{view:t,navButtons:e}=this.options;return t=this.evalValues(t,{}),(e=this.evalValues(e)).length>0&&e.map(t=>{if(\"string\"==typeof t.tapped){let e=t.tapped;t.tapped=()=>{this.evalValues(e)}}return t.handler=t.tapped,t}),new Promise((i,s)=>{if(this.setting.isUseJsboxNav){let s={title:this.title,props:t.props??{},views:[t],disappeared:()=>i()};e.length>0&&(s.navButtons=e),m.push(s)}else{let s=new N;s.setView(t).navigationBarTitle(this.title),s.navigationBarItems.addPopButton(),s.navigationBar.setLargeTitleDisplayMode(O.largeTitleDisplayModeNever),this.setting.hasSectionTitle(t)&&s.navigationBar.setContentViewHeightOffset(-10),e.length>0&&s.navigationBarItems.setRightButtons(e),this.setting.viewController.setEvent(\"onPop\",()=>i()),this.setting.viewController.push(s)}})}getView(){return{type:\"view\",props:{id:this.id,selectable:!0,info:{key:this.key}},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"chevron.right\",bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},events:{tapped:()=>this.tapped()},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(p.edgeOffset),t.height.equalTo(e.super)}}],layout:$layout.fill}}},Z=class extends X{with({children:t}={}){return super.with({view:()=>this.setting.getListView(t,{},this.id)}),this.options.children=t,this}},Q=class extends p{getImagePath(t=!1){let e=$text.MD5(this.key)+\".jpg\";return t&&(e=\"compress.\"+e),this.setting.imagePath+e}getImage(t=!1){try{return this.setting.fileStorage.readSync(this.getImagePath(t))}catch(t){if(t instanceof T)return null;throw t}}get(t=null){return this.getImage(!1)??null}getView(){let t=`${this.id}-image`,e=$image(\"questionmark.square.dashed\"),i=e=>async()=>{$(t).hidden=!0,$(`${t}-spinner`).hidden=!1,await $wait(.1);try{await e()}catch(t){$ui.alert({title:$l10n(\"ERROR\"),message:String(t)})}await $wait(.1),$(`${t}-spinner`).hidden=!0,$(t).hidden=!1},s=[{title:$l10n(\"PREVIEW\"),handler:i(()=>{let t=this.getImage(!1);t?g.quickLookImage(t):$ui.toast($l10n(\"NO_IMAGE\"))})},{inline:!0,items:[{title:$l10n(\"SELECT_IMAGE_PHOTO\"),handler:i(async()=>{let e=await $photo.pick({format:\"data\"});if(!e.status||!e.data){if(e?.error?.description!==\"canceled\")throw Error(e?.error?.description);return}let i=m.compressImage(e.data.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e.data),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))})},{title:$l10n(\"SELECT_IMAGE_ICLOUD\"),handler:i(async()=>{let e=await $drive.open();if(!e)return;let i=m.compressImage(e.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))})}]},{title:$l10n(\"CLEAR_IMAGE\"),destructive:!0,handler:i(()=>{this.setting.fileStorage.delete(this.getImagePath(!0)),this.setting.fileStorage.delete(this.getImagePath()),$(t).image=e,$ui.success($l10n(\"SUCCESS\"))})}];return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{id:t,image:this.getImage(!0)?.image??e},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"spinner\",props:{id:`${t}-spinner`,loading:!0,hidden:!0},layout:(t,e)=>{t.size.equalTo(e.prev),t.left.top.equalTo(e.prev)}},{type:\"button\",props:{menu:{pullDown:!0,asPrimary:!0,items:s},bgcolor:$color(\"clear\")},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}}],layout:(t,e)=>{t.right.inset(0),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},tt=class extends n{name;setting={};settingItems={};userData;fileStorage;logger;imagePath;viewController=new _;method={readme:()=>{let t=(()=>{let t=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[t]??__README__[\"README.md\"]}catch{return $file.read(t)?.string??$file.read(\"README.md\")?.string}})();new g().setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).addNavBar({title:\"README\",popButton:{symbol:\"x.circle\"}}).init().present()}};#t=!1;#e=!1;#i;constructor(t={}){super(),\"function\"==typeof t.set&&\"function\"==typeof t.get?(this.set=t.set,this.getOriginal=t.get,this.setUserData(t.userData??{})):(this.fileStorage=t.fileStorage??new r,this.dataFile=t.dataFile??\"setting.json\"),t.structure?this.setStructure(t.structure):this.setStructurePath(t.structurePath??\"setting.json\"),this.logger=t.logger??new h,this.isUseJsboxNav=t.isUseJsboxNav??!1,this.imagePath=(t.name??\"default\")+\".image/\",this.setName(t.name??$text.uuid)}useJsboxNav(){return this.isUseJsboxNav=!0,this}#s(){if(!this.#e)throw new E}loader(t){let e=null;switch(t.type){case\"info\":e=new q(t);break;case\"switch\":e=new M(t);break;case\"string\":e=new F(t);break;case\"stepper\":e=new U(t).with({min:t.min??1,max:t.max??12});break;case\"script\":e=new H(t).with({script:t.script??t.value});break;case\"tab\":e=new j(t).with({items:t.items,values:t.values});break;case\"menu\":e=new z(t).with({items:t.items,values:t.values,pullDown:t.pullDown??!1});break;case\"color\":e=new W(t);break;case\"date\":e=new K(t).with({mode:t.mode});break;case\"input\":e=new G(t).with({secure:t.secure});break;case\"number\":e=new J(t);break;case\"icon\":e=new Y(t).with({bgcolor:t.bgcolor});break;case\"push\":e=new X(t).with({view:t.view,navButtons:t.navButtons});break;case\"child\":e=new Z(t).with({children:t.children});break;case\"image\":e=new Q(t);break;default:(e=t).default=t.value,e.get=(...t)=>this.get(...t),e.set=(...t)=>this.set(...t)}return e}loadConfig(){this.#e=!1;let t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{}),e=i=>{for(let s in i)for(let n in i[s].items){let a=i[s].items[n];a instanceof p||(i[s].items[n]=this.loader(a),a=i[s].items[n]),a.setting||(a.setting=this),this.settingItems[a.key]=a,a instanceof Z?e(a.options.children):a instanceof H||a instanceof q||(a.key in t?this.setting[a.key]=t[a.key]:this.setting[a.key]=a.default)}};return e(this.structure),this.#e=!0,this}hasSectionTitle(t){return this.#s(),!!t[0]?.title}setUserData(t){return this.userData=t,this}setStructure(t){return this.structure=t,this.loadConfig()}setStructurePath(t){return this.structure||this.setStructure(r.readFromRootAsJSON(t)),this}setName(t){return this.name=t,this}set footer(t){this.#i=t}get footer(){if(void 0===this.#i){let t=r.readFromRootAsJSON(\"config.json\",{}).info??{};if(!t.version||!t.author)try{t=__INFO__}catch{}this.#i={},t.version&&t.author&&(this.#i={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${t.version} \\u2665 ${t.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:t=>{t.left.right.inset(0),t.top.inset(10)}}]})}return this.#i}setFooter(t){return this.footer=t,this}setReadonly(){return this.#t=!0,this}set(t,e){if(this.#t)throw new S;return this.#s(),this.setting[t]=e,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",t,e),!0}getOriginal(t,e=null){return this.#s(),Object.prototype.hasOwnProperty.call(this.setting,t)?this.setting[t]:e}getItem(t){return this.settingItems[t]}get(t,e=null){return this.#s(),this.getItem(t) instanceof p?this.getItem(t).get(e):this.getOriginal(t,e)}#n(t){let e=[];for(let i in t){let s=[];for(let e in t[i].items){let n=t[i].items[e];n instanceof p&&s.push(n.create())}e.push({title:$l10n(t[i].title??\"\"),rows:s})}return e}getListView(t=this.structure,e=this.footer,i=this.name){return{type:\"list\",props:{id:i,style:2,separatorInset:$insets(0,p.iconSize+2*p.edgeOffset,0,p.edgeOffset),footer:e,data:this.#n(t)},layout:$layout.fill,events:{rowHeight:(t,e)=>(t.object(e)?.props?.info??{}).rowHeight??p.rowHeight,didSelect:async(t,e,i)=>{t=t.ocValue();let s=this.getItem(i.props.info.key);if(\"function\"==typeof s?.tapped){t.$selectRowAtIndexPath_animated_scrollPosition(e.ocValue(),!1,0);try{await s.tapped()}catch(t){this.logger.error(t)}}t.$deselectRowAtIndexPath_animated(e,!0)}}}}getNavigationView(){let t=new N;return t.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&t.navigationBar.setContentViewHeightOffset(-10),t}getPage(){return this.getNavigationView().getPage()}},te=class extends x{constructor(t,e){super(t,e),this.name=\"SheetViewTypeError\"}},ti=class extends b{constructor(t={}){super(t),this.setIcon(t.icon),this.setTitle(t.title),void 0!==t.activeStatus&&(this.activeStatus=t.activeStatus)}setIcon(t){return t instanceof Array?this.icon=t:this.icon=[t,t],this}setTitle(t){return this.title=t,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.super);let i=tn.tabBarHeight/2;t.size.equalTo(i),t.top.inset((tn.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.prev),t.top.equalTo(e.prev.bottom).offset(3)}}],this}},ts=class extends b{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??m.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height-tn.tabBarHeight)},this.views=[b.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},tn=class t extends n{static tabBarHeight=50;#t={};#e={};#i;#s;#n=$text.uuid;#a=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:m.bottomSafeAreaInsets;get selected(){return this.#s}set selected(t){this.switchPageTo(t)}get contentOffset(){return t.tabBarHeight+(this.#i?.height??0)}setPages(t={}){return Object.keys(t).forEach(e=>this.setPage(e,t[e])),this}setPage(t,e){return void 0===this.#s&&(this.#s=t),e instanceof ta?this.#t[t]=e:this.#t[t]=ta.create(e),this.#s!==t&&(this.#t[t].activeStatus=!1),this}switchPageTo(t){this.#t[t]&&this.#s!==t&&($ui.animate({duration:.4,animation:()=>{this.#e[t].active()}}),this.#e[this.#s].inactive(),this.#t[this.#s].hide(),this.#t[t].show(),this.callEvent(\"onChange\",this.#s,t),this.#s=t,this.initBackground())}hideBackground(t=!0){$(this.#a).hidden=!0,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#n).alpha=0}})}showBackground(t=!0){$(this.#a).hidden=!1,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#n).alpha=1}})}initBackground(){let t=this.#t[this.selected];t.scrollable&&$delay(0,()=>{let e=$(t.id).get(t.scrollableView.id),i=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)})}setCells(t={}){return Object.keys(t).forEach(e=>this.setCell(e,t[e])),this}setCell(t,e){return void 0===this.#s&&(this.#s=t),e instanceof ti||(e=new ti({props:{info:{key:t}},icon:e.icon,title:e.title,activeStatus:this.#s===t})),this.#e[t]=e,this}setHeader(t){return this.#i=t,this}#r(){let t=[];return Object.values(this.#e).forEach(e=>{e.setEvent(\"tapped\",t=>{let e=t.info.key;this.switchPageTo(e)}),t.push(e.getView())}),t}#o(){return Object.values(this.#t).map(t=>{if(t.scrollable){let e=t.scrollableView;if(e.props.indicatorInsets){let t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top,t.left,t.bottom+this.contentOffset,t.right)}else e.props.indicatorInsets=$insets(0,0,this.contentOffset,0);if(e.props.contentInset){let t=e.props.contentInset;e.props.contentInset=$insets(t.top,t.left,t.bottom+this.contentOffset,t.right)}else e.props.contentInset=$insets(0,0,this.contentOffset,0);\"function\"==typeof e.assignEvent&&e.assignEvent(\"didScroll\",t=>{let e=t.contentOffset.y-this.contentOffset;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-e<=1?this.hideBackground():this.showBackground()})}return t.definition})}generateView(){let e={type:\"view\",layout:(e,i)=>{e.centerX.equalTo(i.super),e.width.equalTo(i.super),e.top.equalTo(i.super.safeAreaBottom).offset(-t.tabBarHeight),e.bottom.equalTo(i.super)},views:[m.blurBox({id:this.#n}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#r()}}},m.separatorLine({id:this.#a},m.align.top)],events:{ready:()=>this.initBackground()}};return b.createFromViews(this.#o().concat(this.#i?.definition??[],e))}},ta=class extends b{constructor(t={}){super(t),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(t){return this.horizontalSafeArea=t,this}#t(t,e){t.top.bottom.equalTo(e.super),this.horizontalSafeArea?t.left.right.equalTo(e.super.safeArea):t.left.right.equalTo(e.super)}getView(){return this.layout=this.#t,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}},tr=class extends u{#t;user;password;#e;namespace=\"JSBox.WebDAV\";lockTokenCacheKey=this.namespace+\".lockToken\";get host(){return this.#t}set host(t){for(this.#t=t.trim();this.#t.endsWith(\"/\");)this.#t=this.#t.substring(0,this.#t.length-1);this.#t.startsWith(\"http\")||(this.#t=\"http://\"+this.#t)}get basepath(){return this.#e}set basepath(t){for(this.#e=t.trim();this.#e.endsWith(\"/\");)this.#e=this.#e.substring(0,this.#e.length-1);for(;this.#e.startsWith(\"/\");)this.#e=this.#e.substring(1);this.#e=\"/\"+this.#e}constructor({host:t,user:e,password:i,basepath:s=\"\"}={}){super(),this.host=t,this.user=e,this.password=i,this.basepath=s}#i(t){return t=(t=t.trim()).startsWith(\"/\")?t:\"/\"+t,this.basepath+t}async request(t,e,i=null,s={}){return s=Object.assign({\"Content-Type\":\"text/xml; charset=UTF-8\",Authorization:\"Basic \"+$text.base64Encode(`${this.user}:${this.password}`)},s),await super.request(this.host+this.#i(t),e,i,s)}async allow(t){let e=await this.request(t,u.method.options);return(e.response.headers?.allow??e.response.headers?.Allow)?.split(\",\").map(t=>t.trim().toUpperCase())??[]}async propfind(t,e=[],i=0){Array.isArray(e)||(e=[e]);let s=`${e.map(t=>``).join()}`,n=await this.request(t,\"PROPFIND\",s,{Depth:i});return $xml.parse({string:n.data})}async propfindAll(t,e=0){let i=await this.request(t,\"PROPFIND\",'',{Depth:e});return $xml.parse({string:i.data})}async ls(t,e=1){let i=await this.request(t,\"PROPFIND\",null,{Depth:e});return $xml.parse({string:i.data})}async exists(t){try{return(await this.allow(t)).includes(u.method.get)?await this.request(t,u.method.head):await this.ls(t,0),!0}catch(t){if(t?.code===404)return!1;throw t}}async mkdir(t){return await this.request(t,\"MKCOL\")}async get(t){return await this.request(t,u.method.get,null)}async put(t,e,{withLock:i=!0,waitInterval:s=2,maxTry:n=3}={}){let a={};for(;await this.isLocked(t);){if(--n<=0)throw Error(\"Resource Locked\");await $wait(s)}if(i)try{await this.lock(t),a.If=`(${this.#n(t)})`}catch(t){if(404!==t.code)throw t;i=!1}await this.request(t,u.method.put,e,a),i&&await this.unlock(t)}async delete(t){if(!t)throw Error(\"path empty\");return await this.request(t,u.method.delete)}#s(t,e){let i=$cache.get(this.lockTokenCacheKey)??{};i[t]=e,$cache.set(this.lockTokenCacheKey,i)}#n(t){return($cache.get(this.lockTokenCacheKey)??{})[t]}async isSupportLock(t){try{return!!(await this.propfind(t,\"supportedlock\")).rootElement.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:supportedlock/D:lockentry\"}).firstChild({xPath:\"//D:locktype/D:write\"})}catch(t){if(404!==t.code)return!1;throw t}}async lock(t,{infinity:e=!1,timeout:i=\"Second-10\"}={}){if(!await this.isSupportLock(t))throw Error(\"Your WebDAV service does not support the `LOCK` method.\");let s=`${this.namespace}`,n=await this.request(t,\"LOCK\",s,{Timeout:i,Depth:e?\"infinity\":0}),a=n.response.headers[\"lock-token\"]??n.response.headers[\"Lock-Token\"];return this.#s(t,a),$xml.parse({string:n.data})}async isLocked(t){try{let e=(await this.propfind(t,\"lockdiscovery\")).rootElement;if(e.firstChild({xPath:\"//D:response/D:propstat/D:status\"}).string.includes(\"404\"))await this.lock(t,{timeout:\"Second-0\"});else{let i=e.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:lockdiscovery\"}).children()??[];for(let e=0;e$objc_clean()}),this.fileStorage=g.fileStorage,this.logger=new r,this.logger.setWriter(this.fileStorage,this.logFilePath),this.setting=new l({logger:this.logger,fileStorage:this.fileStorage,structure:c}),this.initComponents()}get storage(){return this.#l||(this.logger.info(\"init storage\"),this.#l=new d(this)),this.#l}get isWebdavEnabled(){return this.setting.get(\"webdav.status\")}initComponents(){this.clips=new u(this),this.actions=new p(this),this.fileManager=new h}}t.exports={AppKernelBase:g}}),a(\"2EAPF\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.SettingInfo,r=i.SettingScript,o=i.SettingTab,l=n(\"1tFrB\"),h=n(\"fEWdA\");let c={items:[new r({icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\"}).with({script:\"this.method.fileManager\"})].concat(s.isTaio?[]:[new o({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"mainUIDisplayMode\",value:0}).with({items:[\"CLASSIC\",\"MODERN\"]}).onSet(()=>$delay(.3,()=>$addin.restart()))])},d={items:[new a({icon:[\"icon_177\",\"black\"],title:\"Github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]}),new a({icon:[\"icon_172\",\"#1888bf\"],title:\"Telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]}),new a({icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]}),new r({icon:\"arrow.2.circlepath\",title:\"CHECK_UPDATE\"}).with({script:\"this.method.checkUpdate\"}),new r({icon:[\"book.fill\",\"#A569BD\"],title:\"README\"}).with({script:\"this.method.readme\"})]};t.exports=[l,c,h,d]}),a(\"1tFrB\",function(t,e){var i=n(\"gxpqj\").UIKit,s=n(\"3dE3D\"),a=n(\"2jPf3\"),r=n(\"iN4Y6\"),o=n(\"knZRr\"),l=n(\"aziQd\"),h=n(\"5xoIG\");t.exports={items:[s,a,r].concat(i.isTaio?[]:[o,l,h])}}),a(\"3dE3D\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingScript,r=i.SettingNumber,o=i.SettingPush,l=i.SettingChild;t.exports=new l({icon:[\"doc.on.clipboard\",\"#FFCC66\"],title:\"CLIPS\"}).with({children:[{items:[new s({icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",key:\"clipboard.universal\",value:!0}),new a({icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\"}).with({script:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"})]},{items:[new o({icon:[\"trash\",\"red\"],title:\"RECYCLE_BIN\",key:\"clipboard.recycleBin\"}).with({view:\"this.method.recycleBin\",navButtons:\"this.method.recycleBinNavButtons\"})]},{items:[new r({icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",key:\"clipboard.maxItemLength\",value:100}),new s({icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",key:\"clipboard.autoSave\",value:!0})]},{items:[new a({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportClipboard\"}),new a({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importClipboard\"})]},{items:[new a({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\"}).with({script:\"this.method.rebuildDatabase\"}),new a({icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\"}).with({script:\"this.method.deleteAllData\"})]}]})}),a(\"2jPf3\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingScript,a=i.SettingChild;t.exports=new a({icon:[\"bolt.circle\",\"#FF6633\"],title:\"ACTIONS\"}).with({children:[{items:[new s({icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",value:\"this.method.importExampleAction\"}).with({script:\"this.method.importExampleAction\"})]},{items:[new s({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportAction\"}),new s({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importAction\"})]},{items:[new s({icon:[\"square.and.pencil\",\"blue\"],title:\"DEIT_CATEGORY\"}).with({script:\"this.method.editCategory\"})]},{items:[new s({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\"}).with({script:\"this.method.rebuildAction\"})]}]})}),a(\"iN4Y6\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingInput,r=i.SettingNumber,o=i.SettingChild;t.exports=new o({icon:[\"pencil.circle\",\"#CC0099\"],title:\"EDITOR\"}).with({children:[{title:\"CLIPS\",items:[new r({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",key:\"editor.text.insets\",value:300})]},{title:\"CODE\",items:[new s({icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",key:\"editor.code.lineNumbers\",value:!1}),new a({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"}),new a({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"})]}]})}),a(\"knZRr\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingStepper,r=i.SettingScript,o=i.SettingTab,l=i.SettingNumber,h=i.SettingPush,c=i.SettingChild,d=i.SettingImage;t.exports=new c({icon:[\"keyboard\",\"#a2a5a6\"],title:\"KEYBOARD\"}).with({children:[{items:[new h({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\",key:\"keyboard.previewAndHeight\",value:267}).with({view:\"this.method.previewKeyboard\"})]},{items:[new o({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"keyboard.displayMode\",value:0}).with({items:[\"LIST\",\"MATRIX\"]}),new l({icon:[\"textformat.size\"],title:\"FONT_SIZE\",key:\"keyboard.fontSize\",value:16}),new s({icon:[\"checkerboard.rectangle\",\"#1899c4\"],title:\"USE_BLUR\",key:\"keyboard.blur\",value:!1}),new d({icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",key:\"keyboard.background.image\"})]},{items:[new r({icon:[\"pin\",\"#FFCC33\"],title:\"PIN_ACTION\"}).with({script:\"this.method.keyboardPinAction\"})]},{items:[new s({icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",key:\"keyboard.switchAfterInsert\",value:!1}),new s({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",key:\"keyboard.tapticEngine\",value:!0}),new a({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_LEVEL\",key:\"keyboard.tapticEngineLevel\",value:1}).with({min:0,max:2}),new r({icon:\"paperplane\",title:\"QUICK_START_SCRIPTS\"}).with({script:\"this.method.setKeyboardQuickStart\"})]},{items:[new l({icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",key:\"keyboard.deleteDelay\",value:.05})]}]})}),a(\"aziQd\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingScript,a=i.SettingMenu,r=i.SettingChild;t.exports=new r({icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],title:\"WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewWidget\"})]},{title:\"2x2\",items:[new a({icon:\"link\",title:\"CLICK_ACTION\",key:\"widget.2x2.widgetURL\",value:2}).with({pullDown:!0,items:[\"ADD\",\"ACTIONS\",\"CLIPS\"]})]}]})}),a(\"5xoIG\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingScript,a=i.SettingChild;t.exports=new a({icon:[\"filemenu.and.selection\",\"#ebcc34\"],title:\"TODAY_WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewTodayWidget\"})]},{items:[new s({icon:\"bolt.circle\",title:\"ACTIONS\"}).with({script:\"this.method.setTodayWidgetActions\"})]}]})}),a(\"fEWdA\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.SettingChild;let r=[{items:[n(\"fiqsI\")]}];if(!s.isTaio){let t=n(\"fOPZH\");r.push({items:[t]})}t.exports={items:[new a({icon:\"wrench.and.screwdriver\",title:\"EXPERIMENTAL\"}).with({children:r})]}}),a(\"fiqsI\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingInput,r=i.SettingChild;t.exports=new r({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\"}).with({children:[{items:[new s({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\",key:\"webdav.status\",value:!1})]},{items:[new a({icon:\"link\",title:\"HOST\",key:\"webdav.host\",value:\"\"}),new a({icon:\"person\",title:\"USER\",type:\"input\",key:\"webdav.user\",value:\"\"}),new a({icon:\"person.badge.key\",title:\"PASSWORD\",type:\"input\",key:\"webdav.password\",value:\"\"}),new a({icon:\"link\",title:\"BASEPATH\",type:\"input\",key:\"webdav.basepath\",value:\"\"})]}]})}),a(\"fOPZH\",function(t,e){var i=n(\"gxpqj\").SettingScript;t.exports=new i({icon:[\"square.and.arrow.up\",\"#FF9900\"],title:\"ADD_TO_TAIO\"}).with({script:()=>{$ui.alert({title:$l10n(\"ADD_TO_TAIO\"),message:$l10n(\"SELECT_TAIO_APP\")}),$share.sheet([{name:\"CAIO.json\",data:$file.read(\"dist/CAIO.json\")}])}})}),a(\"jEwwi\",function(t,e){var i=n(\"gxpqj\").UIKit,s=n(\"7GYtH\");class a{fileStorage;fsPath;imagePath;#h;static isImage(t=\"\"){return t?.startsWith(\"@image=\")}static pathToKey(t){return t=JSON.stringify(t),`@image=${t}`}static keyToPath(t){return!!a.isImage(t)&&JSON.parse(t.slice(7))}constructor({uuid:t,section:e,text:i=\"\",tag:s=null,prev:n=null,next:a=null}={}){if(!t)throw Error(\"Clip create faild: uuid undefined\");if(!e)throw Error(\"Clip create faild: section undefined\");this.uuid=t,this.section=e,this.text=i,this.tag=s,this.prev=n,this.next=a}get text(){return this.#h}set text(t){this.#h=t,a.isImage(t)&&this.#c(a.keyToPath(t))}get hasTag(){return null!==this.tag}get image(){return a.isImage(this.text)}get imageOriginal(){return this.#d(\"original\")}get imagePreview(){return this.#d(\"preview\")}#d(t){if(this.image&&this.fileStorage.exists(this.fsPath[t]))return this.fileStorage.readSync(this.fsPath[t])}#c(t){this.fileStorage&&(this.fsPath=t,this.imagePath={original:this.fileStorage.filePath(t.original),preview:this.fileStorage.filePath(t.preview)})}}class r{sqlite;constructor(t){this.kernel=t,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`;let e=\"/image\";this.imagePath={base:e,original:`${e}/original`,preview:`${e}/preview`},this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.initWebdavSync(),this.init()}async initWebdavSync(){if(this.kernel.isWebdavEnabled)try{this.webdavSync=new s({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.logger.error(t),t}}needUpload(){this.webdavSync&&this.webdavSync.needUpload()}sync(){this.webdavSync&&this.webdavSync.sync()}init(){this.sqlite&&this.sqlite.close();let t=this.kernel.fileStorage.filePath(this.localDb);$file.exists(t)||$file.write({data:$data({string:\"\"}),path:this.kernel.fileStorage.filePath(this.localDb)}),this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\"),this.kernel.logger.info(\"init database\")}rebuild(){let t=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(t);let e=new r(this.kernel);e.localDb=t,e.init();let i=(t,i)=>{let s=[];t.forEach(t=>{let n=new a({uuid:t.uuid,text:t.text,section:t.section,tag:t.tag,prev:null,next:s[0]?.uuid??null});e.beginTransaction();try{e.insert(n),n.next&&(s[0].prev=n.uuid,s[0].section=i,e.update(s[0])),e.commit(),s.unshift(n)}catch(t){throw e.rollback(),this.kernel.logger.error(t),t}})};[\"clips\",\"favorite\"].map(t=>{let e=this.all(t);try{let t=this.sort(e);if(t.length>e.length)throw Error();e=t.reverse()}catch{}i(e,t)});let s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach(t=>{e.beginTransaction();try{e.setTag(t.uuid,t.tag),e.commit()}catch(t){throw e.rollback(),this.kernel.logger.error(t),t}}),this.kernel.fileStorage.copy(t,this.localDb),this.needUpload(),this.kernel.logger.info(\"database rebuild\")}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath.base),this.kernel.fileStorage.delete(this.localDb),this.needUpload(),this.kernel.logger.info(\"delete all database\")}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(t){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath.base,this.tempImagePath);let e=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(e)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(e)})}],handler:i=>{this.kernel.fileStorage.delete(e),t(i)}})}async import(t){if(\"db\"===t.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,t))throw Error($l10n(\"WRITE_DB_FILE_FAILED\"))}else if(\"zip\"===t.fileName.slice(-3)){if(!await $archiver.unzip({file:t,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw Error($l10n(\"UNZIP_FAILED\"));this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath.base)}this.webdavSync&&this.webdavSync.updateLocalTimestamp()}sort(t,e=9e3){let i={},s=0,n=null;t.forEach(t=>{i[t.uuid]=t,null===t.prev&&(n=t.uuid),s++});let a=[];if(s>0)try{let t=i[n];for(;null!==t.next&&e>0;)e--,a.push(t),t=i[t.next];a.push(t)}catch(t){throw\"Unable to sort: \"+t}return a}replaceString(t){return[\"\\\\\",'\"',\"'\",\"%\",\"-\",\"_\",\";\"].forEach(e=>{t=t.replaceAll(e,`\\\\${e}`)}),t}replaceQuotation(t){return[\"\\\\\",'\"',\"'\"].forEach(e=>{t=t.replaceAll(e,`\\\\${e}`)}),t}parse(t){let e=t.result,i=t.error,s=[];try{if(null!==i)throw Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);for(;e.next();){let t=e.get(\"text\"),i=new a({uuid:e.get(\"uuid\"),section:e.get(\"section\"),tag:e.get(\"tag\"),prev:e.get(\"prev\"),next:e.get(\"next\")});a.isImage(t)&&(i.fileStorage=this.kernel.fileStorage),i.text=t,s.push(i)}}catch(t){throw t}finally{e?.close()}return s}parseTag(t){if(null!==t.error)throw t.error;let e=[];for(;t.result.next();)e.push({uuid:t.result.get(\"uuid\"),tag:t.result.get(\"tag\")});return t.result.close(),e}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(t=\"\"){t=this.replaceQuotation(t);let e=this.sqlite.query({sql:`\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE uuid = \"${t}\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = \"${t}\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `});return this.parse(e)[0]}getByText(t=\"\"){t=this.replaceQuotation(t);let e=this.sqlite.query({sql:`\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE text = \"${t}\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text = \"${t}\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `});return this.parse(e)[0]}async search(t){let e=(await $text.tokenize({text:t})).map(t=>this.replaceString(t)),i=`%${e.join(\"%\")}%`,s=this.sqlite.query({sql:`\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE text like \"${i}\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \"${i}\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `});return{result:this.parse(s),keyword:e}}searchByTag(t){t.startsWith(\"#\")&&(t=t.substring(1));let e=this.sqlite.query({sql:`SELECT * FROM tag WHERE tag like \"%${this.replaceString(t)}%\"`}),i=this.parseTag(e),s=[];return i.forEach(t=>{s.push(this.getByUUID(t.uuid))}),{result:s,keyword:[t]}}deleteTable(t){let e=this.sqlite.update(`DELETE FROM ${t}`);if(!e.result)throw e.error;this.needUpload(),this.kernel.logger.info(`delete table ${t}`)}all(t){let e=this.sqlite.query(`SELECT ${t}.*, tag, '${t}' AS section FROM ${t} LEFT JOIN tag ON ${t}.uuid = tag.uuid`);return this.parse(e)}saveImage(t){if(\"object\"==typeof t){let e=$text.uuid,s={original:`${this.imagePath.original}/${e}.png`,preview:`${this.imagePath.preview}/${e}.jpg`};return this.kernel.fileStorage.write(s.original,t.png),this.kernel.fileStorage.write(s.preview,i.compressImage(t).jpg(.8)),a.pathToKey(s)}throw Error(\"saveImageError: image not an object\")}insert(t){let e=this.sqlite.update({sql:`INSERT INTO ${t.section} (uuid, text, prev, next) values (?, ?, ?, ?)`,args:[t.uuid,t.text,t.prev,t.next]});if(!e.result)throw e.error;this.needUpload()}update(t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;let e=this.sqlite.update({sql:`UPDATE ${t.section} SET text = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,t.prev,t.next,t.uuid]});if(!e.result)throw e.error;this.needUpload()}updateText(t,e,i){if(\"string\"!=typeof e)return;let s=this.sqlite.update({sql:`UPDATE ${t} SET text = ? WHERE uuid = ?`,args:[i,e]});if(!s.result)throw s.error;this.needUpload()}delete(t,e){this.getByUUID(e);let i=this.sqlite.update({sql:`DELETE FROM ${t} WHERE uuid = ?`,args:[e]});if(!i.result)throw i.error;this.needUpload()}isEmpty(){let t=this.sqlite.query(\"SELECT * FROM clips limit 1\").result,e=this.sqlite.query(\"SELECT * FROM favorite limit 1\").result;return t.next(),e.next(),t.isNull(0)&&e.isNull(0)}allImageFromDb(t=!0){let e=this.sqlite.query(`\n SELECT a.* from\n (SELECT *, 'clips' AS section FROM clips WHERE text like \"@image=%\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \"@image=%\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `),i=this.parse(e)?.map(t=>{if(t.image){let e=t.fsPath;return e.preview=e.preview.replaceAll(this.imagePath.preview,\"\"),e.preview.startsWith(\"/\")&&(e.preview=e.preview.substring(1)),e.original=e.original.replaceAll(this.imagePath.original,\"\"),e.original.startsWith(\"/\")&&(e.original=e.original.substring(1)),e}}),s=[],n=[];return t||i.forEach(t=>{s.push(t.original),n.push(t.preview)}),t?i:{original:s,preview:n}}localImagesFromFile(){return{original:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.original),preview:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.preview)}}setTag(t,e){let i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[t,e]});if(!i.result)throw i.error;this.needUpload()}deleteTag(t){let e=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[t]});if(!e.result)throw e.error;this.needUpload()}addDir(t){let e=this.sqlite.update({sql:\"INSERT INTO dir (uuid, name) values (?, ?)\",args:[$text.uuid,t]});if(!e.result)throw e.error;this.needUpload()}deleteDir(t){this.beginTransaction();let e=this.sqlite.update({sql:\"DELETE FROM dir WHERE uuid = ?\",args:[t]});if(!e.result)throw this.rollback(),e.error;let i=this.sqlite.update({sql:\"DELETE FROM dir_link WHERE dir_uuid = ?\",args:[t]});if(!i.result)throw this.rollback(),i.error;this.commit(),this.needUpload()}}t.exports={Clip:a,Storage:r}}),a(\"7GYtH\",function(t,e){var i=n(\"gxpqj\").FileStorage,s=n(\"2VUvw\");class a extends s{localSyncDataPath=\"/sync.json\";webdavSyncDataPath=\"/sync.json\";webdavDbPath=\"/CAIO.db\";webdavImagePath=\"/image\";get localDb(){return $data({path:this.kernel.fileStorage.filePath(this.kernel.storage.localDb)})}set localDb(t){this.kernel.fileStorage.writeSync(this.kernel.storage.localDb,t)}get localImagePath(){return this.kernel.fileStorage.filePath(\"/image\")}async init(){await super.init(),await this.initImagePath(),this.sync()}async initImagePath(){await this.webdav.exists(this.webdavImagePath)||(await this.webdav.mkdir(this.webdavImagePath),[\"/image/original\",\"/image/preview\"].map(async t=>{await this.webdav.exists(t)||await this.webdav.mkdir(t)}))}isNew(){return this.kernel.storage.isEmpty()}async webdavImages(){let t=(await this.webdav.ls(this.webdavImagePath,\"infinity\")).rootElement,e=t.firstChild({xPath:\"//D:response/D:href\"}).string,i=[],s=[];return t.children().map(t=>{let n=t.firstChild({tag:\"href\"})?.string?.replaceAll(e,\"\");!n.endsWith(\"/\")&&(n.startsWith(\"original\")?i.push(n.substring(9)):n.startsWith(\"preview\")&&s.push(n.substring(8)))}),{original:i,preview:s}}async syncImages(){let t=await this.webdavImages(),e=this.kernel.storage.allImageFromDb(!1),s=this.kernel.storage.localImagesFromFile();Object.keys(s).map(t=>{s[t].forEach(async s=>{if(!e[t].includes(s)){let e=i.join(this.kernel.storage.imagePath[t],s);this.kernel.fileStorage.delete(e),this.kernel.logger.info(`Local image deleted: ${e}`)}})}),Object.keys(e).map(s=>{e[s].forEach(async e=>{let n=i.join(this.webdavImagePath,s,e),a=i.join(this.kernel.storage.imagePath[s],e);if(t[s].includes(e)&&!this.kernel.fileStorage.exists(a)){let t=await this.webdav.get(n);this.kernel.fileStorage.writeSync(a,t.rawData),this.kernel.logger.info(`WebDAV image downloaded: ${a}`)}else if(!t[s].includes(e)){let t=this.kernel.fileStorage.readSync(a);await this.webdav.put(n,t),this.kernel.logger.info(`WebDAV image uploaded: ${n}`)}})}),Object.keys(t).map(s=>{t[s].forEach(async t=>{if(!e[s].includes(t)){let e=i.join(this.webdavImagePath,s,t);await this.webdav.delete(e),this.kernel.logger.info(`WebDAV image deleted: ${e}`)}})})}async pull(){this.webdav.clearNSURLCache();let t=await this.webdav.get(this.webdavDbPath);this.localDb=t.rawData,await this.downloadSyncData(),this.kernel.storage.init(),await this.syncImages(),this.kernel.logger.info(\"clip webdav sync: pulled\")}async push(){await this.webdav.put(this.webdavDbPath,this.localDb),await this.uploadSyncData(),await this.syncImages(),this.kernel.logger.info(\"clip webdav sync: pushed\")}notify(t){$app.notify({name:\"clipSyncStatus\",object:t})}async #u(){let t=!1;try{let e=await this.nextSyncStep();if(this.kernel.logger.info(`clip nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else if(e===s.step.conflict){if(await this.conflict($l10n(\"CLIPS\"))!==a.conflictKeep.webdav)return;t=!0}else{this.notify({status:s.status.nochange});return}this.notify({status:s.status.success,updateList:t})}catch(t){throw this.notify({status:s.status.fail,error:t}),this.kernel.logger.error(\"clip sync error\"),this.kernel.logger.error(t),t}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,()=>{this.#u()})}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,()=>{this.updateLocalTimestamp(),this.#u()})}}t.exports=a}),a(\"2VUvw\",function(t,e){var i=n(\"gxpqj\").WebDAV;class s{static step={init:-1,stay:0,needPush:2,needPull:3,conflict:4};static stepName=(()=>{let t={};return Object.keys(s.step).map(e=>{t[s.step[e]]=String(e)}),t})();static status={syncing:0,success:1,nochange:2,fail:3};static conflictKeep={local:0,webdav:1,cancel:2};static initLocalTimestamp=0;webdav;kernel;localSyncDataPath;webdavSyncDataPath;constructor({host:t,user:e,password:s,basepath:n,kernel:a}={}){this.kernel=a,this.webdav=new i({host:t,user:e,password:s,basepath:n}),this.webdav.namespace=\"JSBox.CAIO\"}get mustLocalSyncDataPath(){if(!this.localSyncDataPath)throw Error(\"localSyncDataPath not set\");return this.localSyncDataPath}get mustWebdavSyncDataPath(){if(!this.webdavSyncDataPath)throw Error(\"webdavSyncDataPath not set\");return this.webdavSyncDataPath}get localSyncData(){return this.kernel.fileStorage.exists(this.mustLocalSyncDataPath)||(this.localSyncData={timestamp:s.initLocalTimestamp}),this.kernel.fileStorage.readSync(this.mustLocalSyncDataPath)}set localSyncData(t){this.kernel.fileStorage.writeSync(this.mustLocalSyncDataPath,$data({string:JSON.stringify(t)}))}get localTimestamp(){return Number(JSON.parse(this.localSyncData.string).timestamp)}set localTimestamp(t){this.localSyncData=Object.assign(this.localSyncData,{timestamp:t})}async init(t=this.webdav.basepath){let e=new i({host:this.webdav.host,user:this.webdav.user,password:this.webdav.password,basepath:t});if(!await e.exists(\"/\"))try{await e.mkdir(\"/\")}catch(e){if(409===e.code){await this.init(t.substring(0,t.lastIndexOf(\"/\"))),await this.init(t);return}throw e}}isNew(){return!1}async webdavSyncData(){this.webdav.clearNSURLCache();let t=(await this.webdav.get(this.mustWebdavSyncDataPath)).data;return\"string\"==typeof t&&(t=JSON.parse(t)),t}async webdavTimestamp(){try{let t=await this.webdavSyncData();return Number(t.timestamp)}catch(t){if(404===t.code)return s.step.init;throw t}}updateLocalTimestamp(){this.localTimestamp!==s.initLocalTimestamp&&(this.localTimestamp=Date.now())}async uploadSyncData(){this.localTimestamp===s.initLocalTimestamp&&(this.localTimestamp=Date.now()),await this.webdav.put(this.mustWebdavSyncDataPath,this.localSyncData)}async downloadSyncData(){this.localSyncData=await this.webdavSyncData()}async nextSyncStep(){let t=this.localTimestamp,e=await this.webdavTimestamp();return e===s.step.init?s.step.init:e===s.initLocalTimestamp?(this.localTimestamp=Date.now(),await this.push(),s.step.stay):t>e?s.step.needPush:t===e?s.step.stay:t{!this.needReload&&$(this.views.listId).ocValue().$isEditing()||(this.updateList(!0),$delay(.5,()=>{this.readClipboard()}))},clipSyncStatus:t=>{let e=$(this.views.listId);t.status===g.status.success||t.status===g.status.nochange?(t.updateList&&this.updateList(!0),e&&e.endRefreshing()):t.status===g.status.syncing&&t.animate&&e&&e.beginRefreshing()}})}setDelegate(){this.delegates.setEditingCallback(t=>{this.navigationView.navigationBarItems.getButtons().forEach(e=>{e.id===this.views.listId+\"-navbtn-edit\"?e.setTitle(t?$l10n(\"DONE\"):$l10n(\"EDIT\")):t?e.hide():e.show()})}),this.delegates.setDelegate()}listReady(){this.setDelegate(),this.updateList(),$delay(.5,()=>{this.readClipboard()}),a.isTaio||($delay(.5,()=>{if($context.query.copy){let t=$context.query.copy;this.setCopied(t),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions?this.kernel.isUseJsboxNav?this.kernel.actions.present():this.kernel.tabBarController.switchPageTo(\"actions\"):$context.query.runAction&&$delay(0,()=>{let t=JSON.parse($text.base64Decode($context.query.runAction));this.kernel.actions.getAction(t.category,t.dir,new m({env:f.widget})).do()})}),this.appListen())}updateList(t=!1){t&&this.setNeedReload(),$(this.views.listId).data=this.clips.map(t=>this.views.lineData(t,this.copied.uuid===t.uuid)),this.updateListBackground()}updateListBackground(){this.clips.length>0?$(this.views.listId).ocValue().$setBackgroundView(void 0):$(this.views.listId).ocValue().$setBackgroundView($ui.create(this.views.getEmptyBackground(this.clips.length>0)))}updateCopied(t=null){let e=this.copied?.uuid;$delay(0,()=>{let i=$(this.views.listId),s=i.cell($indexPath(0,this.getIndexByUUID(e)));if(s&&(s.get(\"copied\").hidden=!0),t){let e=this.getIndexByUUID(t.uuid);i.cell($indexPath(0,e)).get(\"copied\").hidden=!1}}),t?Object.assign(this.copied,t):this.copied={},this.kernel.logger.info(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}focusAnimation(t){$delay(.3,()=>{let e=$(this.views.listId),i=this.getIndexByUUID(t),s=0;for(let t=0;t0){t&&(await $wait(.1),$clipboard.images.forEach(t=>{this.add(t)}));return}let e=$clipboard.text;if(!e||\"\"===e){this.clearCopied();return}if(this.getClip(this.copied?.uuid)?.text===e){t&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")),this.switchTab(this.tabItemsMap[this.copied.section],!0),this.focusAnimation(this.copied.uuid);return}if(this.exists(e)){let t=this.kernel.storage.getByText(e);this.switchTab(this.tabItemsMap[t.section],!0),this.setCopied(t.uuid)}else{this.switchTab(1,!0);let t=await this.add(e);this.setCopied(t.uuid)}}}async add(t,e=!0){try{let i=super.addItem(t);if(!e)return;return this.updateListBackground(),await $wait(.1),$(this.views.listId).insert({indexPath:$indexPath(0,0),value:this.views.lineData(i)}),i}catch(t){$ui.warning(t)}}delete(t){try{super.deleteItem(t),this.copied.uuid===t&&(this.updateCopied(),$clipboard.clear()),this.updateListBackground()}catch(t){$ui.alert(t)}}update(t,e){try{return super.updateItem(t,e),this.updateList(),e===this.copied.uuid&&this.setClipboardText(t),!0}catch(t){return $ui.alert(t),!1}}favorite(t){let e=this.getByIndex(t);if(e?.section===\"favorite\")return;let i=this.kernel.storage.getByUUID(e.uuid);if(i?.section===\"favorite\"){h.warning(\"Already exists\");return}try{super.favoriteItem(e.uuid),$(this.views.listId).delete(t)}catch(t){$ui.alert(t)}}copy(t){let e=this.getClip(t);if(e.image?$clipboard.image=e.imageOriginal:this.setCopied(t,!1),0!==this.tabIndex){let e=this.getIndexByUUID(t);try{super.moveItem(e,0);let t=$(this.views.listId).ocValue(),i=$indexPath(0,e).ocValue(),s=$indexPath(0,0).ocValue();t.$moveRowAtIndexPath_toIndexPath(i,s)}catch(t){$ui.alert(t)}}}getAddTextView(){this.views.edit(\"\",t=>{\"\"!==t&&this.add(t)})}switchTab(t,e=!1){this.tabIndex=t,this.updateList(),e&&($(this.views.listId+\"-tab\").index=this.tabIndex),this.delegates.setEditing(!1)}getTabView(){return this.views.tabView(this.tabItems,this.tabIndex,{changed:t=>this.switchTab(t.index)})}getListView(){return this.views.getListView(this.views.listId,[],{ready:()=>this.listReady(),pulled:t=>{this.updateList(!0),this.kernel.storage.sync(),this.kernel.setting.get(\"webdav.status\")||$delay(.5,()=>t.endRefreshing())}})}getNavigationView(){let t=new d(this.kernel);t.setCallback(e=>{let i=new r,s=(t=>{let{keyword:e,result:s,isTagKeyword:n}=t;return this.views.getListView(this.views.listId+\"-search-result\",s.map(t=>{let i=n?t.tag:t.text,s=[];return e.forEach(t=>{let e=i.indexOf(t);for(;e>-1;)s.push({range:$range(e,t.length),color:$color(\"red\")}),e=i.indexOf(t,e+1)}),t.styledText={},n?t.tagStyledText={color:this.views.tagColor,text:i,styles:s}:t.textStyledText={text:i,styles:s},this.views.lineData(t,!1)}),{ready:()=>this.updateList(),didSelect:(t,e)=>{let n=s[e.row];n.image?r.quickLookImage(n.imageOriginal):(i.dismiss(),this.views.edit(n.text,t=>{n.text!==t&&this.update(t,n.uuid)}))},rowHeight:(t,e)=>{let i=s[e.row],n=i?.hasTag?this.views.tagHeight:this.views.verticalMargin,a=i.image?this.views.imageContentHeight:this.views.getContentHeight(i.text);return this.views.verticalMargin+a+n}})})(e);s.props.bgcolor=a.primaryViewBackgroundColor,i.setView(s).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>t.dismiss()}}).init().present()});let e=this.getTabView();e.type=\"menu\",e.layout=(t,e)=>{t.left.right.equalTo(e.super),t.height.equalTo(this.views.tabHeight),this.kernel.isUseJsboxNav&&a.isTaio?t.top.equalTo(e.super).offset(a.PageSheetNavigationBarNormalHeight):t.top.equalTo(e.super)};let i=s.createFromViews([e,this.getListView(),t.getSearchHistoryView()]);return this.navigationView=new o().navigationBarTitle($l10n(\"CLIPS\")).setView(i),this.navigationView.navigationBarItems.setTitleView(t.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{id:this.views.listId+\"-navbtn-edit\",title:$l10n(\"EDIT\"),tapped:()=>this.delegates.setEditing()},{symbol:\"square.and.arrow.down.on.square\",tapped:async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){t.cancel(),this.kernel.logger.error(e)}}}]),this.navigationView.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(l.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&this.navigationView.navigationBar.removeTopSafeArea(),this.navigationView}}t.exports=w}),a(\"ZnuTV\",function(t,e){var i=n(\"gxpqj\").UIKit,s=n(\"jEwwi\").Clip;class a{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#p=[];clipsUUIDMap={};rememberTabIndex=!0;#g=0;tabItems=[$l10n(\"FAVORITE\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"favorite\",\"clips\"];tabItemsMap=(function(t){let e={};return t.forEach((t,i)=>{e[t]=i}),e})(this.tabItemsIndex);constructor(t){this.kernel=t}get tabIndex(){return this.rememberTabIndex?$cache.get(\"caio.main.tab.index\")??0:this.#g}set tabIndex(t){this.rememberTabIndex?$cache.set(\"caio.main.tab.index\",t):this.#g=t}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return this.tabItemsIndex.forEach((t,e)=>{this.#p[e]||(this.#p[e]=this.#y(t),this.kernel.logger.info(`init clips: ${t}`))}),this.#p}get clips(){return this.#p[this.tabIndex]||(this.#p[this.tabIndex]=this.#y(this.table),this.kernel.logger.info(`init clips: ${this.table}`)),this.#p[this.tabIndex]}get isPasteboardChanged(){let t=this.pasteboard.$changeCount();return $cache.get(\"clipboard.changeCount\")!==t&&($cache.set(\"clipboard.changeCount\",t),!0)}get needReload(){return $cache.get(\"caio.needReload\")??!1}set needReload(t){$cache.get(\"caio.needReload\",t)}#y(t){try{let e=this.kernel.storage.all(t),i=this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\"));return i.forEach((e,i)=>{this.clipsUUIDMap[e.uuid]={tab:t,index:i}}),this.#f(i)}catch(t){this.kernel.logger.error(t),this.rebuildDatabase()}}#f(t){return new Proxy(t??[],{set:(t,e,i)=>Reflect.set(t,e,i),get:(t,e)=>Reflect.get(t,e)})}rebuildDatabase(){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{let t=i.loading();t.start(),this.kernel.storage.rebuild(),t.end(),$delay(.8,()=>$addin.restart())}},{title:$l10n(\"CANCEL\")}]})}setNeedReload(t){t?this.#p[this.tabItemsMap[t]]=null:this.#p=[],this.needReload=!0,this.kernel.logger.info(`set need reload: ${t??\"all\"}`)}getClipCopy(t,e={}){if(!t.uuid)return t;let i=new s(t);return i.fileStorage=t.fileStorage,Object.assign(i,e),i}getIndexByUUID(t){return this.clipsUUIDMap[t]?.index??-1}getClip(t){return this.clips[this.getIndexByUUID(t)]||this.kernel.storage.getByUUID(t)}exists(t){try{let e=this.kernel.storage.getByText(t);return void 0!==e}catch{return!1}}setClipboardText(t){this.kernel.setting.get(\"clipboard.universal\")?$clipboard.text=t:$clipboard.setTextLocalOnly(t)}addItem(t){if(this.exists(t))throw Error(\"Item already exists\");let e=new s({uuid:$text.uuid,section:this.table,prev:null,next:this.clips[0]?this.clips[0].uuid:null});if(\"string\"==typeof t){if(\"\"===t.trim())return;e.text=t}else{if(\"object\"!=typeof t)return;e.fileStorage=this.kernel.fileStorage,e.text=this.kernel.storage.saveImage(t)}try{return this.kernel.storage.beginTransaction(),this.kernel.storage.insert(e),e.next&&(this.clips[0].prev=e.uuid,this.kernel.storage.update(this.clips[0])),this.kernel.storage.commit(),this.setNeedReload(this.table),e}catch(t){throw this.kernel.storage.rollback(),this.kernel.logger.error(t),t}}getRecycleBin(){return $cache.get(\"caio.recycleBin\")??[]}moveToRecycleBin(t){let e=this.getRecycleBin();e.push({text:t.text,tag:t.tag}),$cache.set(\"caio.recycleBin\",e)}removeFromRecycleBin(t){let e=this.getRecycleBin();e.splice(t,1),$cache.set(\"caio.recycleBin\",e)}clearRecycleBin(){$cache.set(\"caio.recycleBin\",[])}deleteItem(t,e=!0){let i=this.getIndexByUUID(t),s=this.clips[i],n=this.clips[i-1],a=this.clips[i+1];try{this.kernel.storage.beginTransaction(),this.kernel.storage.delete(this.table,t),n&&(n.next=s.next,this.kernel.storage.update(n)),a&&(a.prev=s.prev,this.kernel.storage.update(a)),this.kernel.storage.commit(),e&&(this.kernel.storage.deleteTag(t),s?.image?(this.kernel.fileStorage.delete(s.fsPath.original),this.kernel.fileStorage.delete(s.fsPath.preview)):this.moveToRecycleBin(s)),this.setNeedReload(this.table)}catch(t){throw this.kernel.storage.rollback(),this.kernel.logger.error(t),t}}updateItem(t,e){let i=this.getClip(e),s=i.text;Object.assign(i,{text:t});try{this.kernel.storage.updateText(this.table,i.uuid,t),this.kernel.logger.info(`data changed at index [${this.getIndexByUUID(e)}]\n${s}\n\\u{2193}\n${t}`)}catch(t){throw this.kernel.logger.error(t),t}}moveItem(t,e){if(t!==e&&1!==this.clips.length){t{};onBegin=()=>{};onDismiss=()=>{};constructor(t){this.kernel=t,this.searchBar=new a,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return s.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(t,e)=>{t.right.equalTo(e.prev.left),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(t,e)=>{let i=t.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(t,e,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(t){this.callback=t}setOnBegin(t){this.onBegin=t}setOnDismiss(t){this.onDismiss=t}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){this.searchBar.cancel()}async searchAction(t){try{if(\"\"!==t){let e=t.startsWith(\"#\"),{result:i,keyword:s}=e?this.kernel.storage.searchByTag(t.substring(1)):await this.kernel.storage.search(t);i&&i.length>0?($(this.searchBarId).blur(),this.callback({keyword:s,result:i,isTagKeyword:e})):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(t)}}catch(t){throw t}}pushSearchHistory(t){let e=$cache.get(\"caio.search.history\")??[];-1===e.indexOf(t)&&(e.push(t),e.length>20&&(e=e.slice(-20)),$cache.set(\"caio.search.history\",e),$(this.listId+\"-history\").data=this.searchHistory)}updateSearchHistory(t=[]){$cache.set(\"caio.search.history\",t)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",t=>{\"\"!==t?this.searchAction(t):this.searchHistoryView.show()}),this.searchBar.controller.setEvent(\"onChange\",t=>{\"\"===t&&this.searchHistoryView.show()}),this.searchBar.controller.setEvent(\"onBeginEditing\",t=>{\"\"===t&&this.begin()}),this.searchBar.controller.setEvent(\"onCancel\",()=>{this.searchHistoryView.hide(),this.onDismiss()}),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}t.exports=r}),a(\"iGysH\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.ViewController,r=n(\"f0nX9\");class o{listId=$text.uuid;editingToolBarId=this.listId+\"-edit-mode-tool-bar\";#m=!1;#w=0;scrollToOffsetDirectionX=!1;tabLeftMargin=20;horizontalMargin=20;verticalMargin=14;containerMargin=0;fontSize=16;copiedIndicatorSize=6;imageContentHeight=50;tagHeight=this.verticalMargin+5;tagColor=$color(\"lightGray\");tabHeight=44;editModeToolBarHeight=44;#$={};viewController;constructor(t){this.kernel=t,this.viewController=new a}get singleLineContentHeight(){return 0===this.#w&&(this.#w=this.getTextHeight($font(this.fontSize))),this.#w}setSingleLine(){this.#m=!0,this.imageContentHeight=this.singleLineContentHeight,this.#w=0}getTextHeight(t,e=\"a\"){return $text.sizeThatFits({text:e,font:t,width:s.windowSize.width-(this.horizontalMargin+this.containerMargin)*2}).height}getContentHeight(t){return this.#$[t]||(this.#$[t]=this.#m?this.singleLineContentHeight:Math.min(this.getTextHeight($font(this.fontSize),t),2*this.singleLineContentHeight)),this.#$[t]}edit(t,e){let i=new r(this.kernel),s=[{symbol:\"square.and.arrow.up\",tapped:()=>{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(t,t=>e(t),s);else{let n=i.getNavigationView(t,t=>e(t),s);this.viewController.push(n)}}tabView(t,e,i){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:t,index:e,dynamicWidth:!0},events:i,layout:(t,e)=>{t.centerY.equalTo(e.super),e.prev?t.left.equalTo(e.prev.right).offset(this.tabLeftMargin):t.left.inset(this.tabLeftMargin)}}}lineData(t,e=!1){let i={hidden:!0},s={text:\"\"},n={hidden:!t?.hasTag};return t.image?(i.data=t.imagePreview,i.hidden=!1):(t.textStyledText?s.styledText=t.textStyledText:s.text=t.text,t.tagStyledText?n.styledText=t.tagStyledText:n.text=t.tag),{copied:{hidden:!e},image:i,tag:n,content:s}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(this.copiedIndicatorSize),t.left.equalTo(e.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#m?1:2,font:$font(this.fontSize)},layout:(t,e)=>{t.left.right.equalTo(e.super).inset(this.horizontalMargin),t.top.equalTo(this.verticalMargin)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.bottom.equalTo(e.super),t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight)}}],layout:$layout.fill},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}getEmptyBackground(t=!1){return{type:\"label\",props:{color:$color(\"secondaryText\"),hidden:t,text:$l10n(\"NONE\"),align:$align.center},events:{ready:t=>{t.layout((t,e)=>{t.top.equalTo(this.tabHeight),t.left.right.bottom.equalTo(e.super)})}}}}getListEditModeToolBarView({selectButtonEvents:t,deleteButtonEvents:e}={}){return s.blurBox({id:this.editingToolBarId},[s.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.editingToolBarId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.inset(this.horizontalMargin),t.centerY.equalTo(e.super)},events:t},{type:\"button\",props:{id:this.editingToolBarId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(2*this.horizontalMargin),t.right.inset(this.horizontalMargin/2),t.centerY.equalTo(e.super)},events:e}],layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom)}}])}getListView(t=this.listId,e=[],i){return{type:\"list\",props:{id:t,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.horizontalMargin,0,0),data:e,allowsMultipleSelectionDuringEditing:!0,template:this.listTemplate(),backgroundView:$ui.create(this.getEmptyBackground())},events:i,layout:(t,e)=>{e.prev?t.top.equalTo(e.prev.bottom):t.top.equalTo(e.super),t.left.right.bottom.equalTo(e.super)}}}}t.exports=o}),a(\"f0nX9\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.NavigationBar,r=i.NavigationView,o=i.Sheet,l=n(\"eSp9Z\"),h=l.ActionEnv,c=l.ActionData;t.exports=class{#h=\"\";originalContent;constructor(t){this.kernel=t,this.id=\"editor\"}set text(t=\"\"){void 0===this.originalContent&&(this.originalContent=t),this.#h=t}get text(){return this.#h}getActionButton(){return{symbol:\"bolt.circle\",tapped:(t,e)=>{e&&(t=e);let i=$(this.id).selectedRange,s=new c({env:h.editor,editor:{originalContent:this.originalContent,setContent:t=>this.setContent(t)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,allText:this.text,selectedText:this.text.slice(i.location,i.location+i.length),selectedRange:i}),n=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actions.views.getActionListView(t=>{n.dismiss(),$delay(.5,()=>t(s))})]})}}}setContent(t){this.text=t,$(this.id).text=t}getView(t=\"text\"){return{type:t,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===t?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:t=>{\"\"===this.text&&$delay(.5,()=>t.focus())},didChange:t=>{this.text=t.text}}}}pageSheet(t=\"\",e,i,s=[],n=\"text\"){this.text=t,s.unshift(this.getActionButton());let a=new o;a.setView(this.getView(n)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>e(this.text)},rightButtons:s}).init(),a.navigationView.navigationBar.contentViewHeightOffset=0,a.present()}getViewController(t,e){return $define({type:\"EditorViewController: UIViewController\",events:{viewDidLoad:()=>{self.$super().$viewDidLoad(),self.$view().jsValue().add(this.getView(t)),self.$navigationItem().$setLargeTitleDisplayMode(2)},\"viewDidDisappear:\":t=>{e()}}}),$objc(\"EditorViewController\").$new()}uikitPush(t=\"\",e,i=[],n=\"text\"){this.text=t,i.unshift(this.getActionButton()),s.push({title:\"\",navButtons:i.map(t=>(t.handler=t.tapped,t.tapped=void 0,t)),views:[this.getView(n)],disappeared:()=>e(this.text)})}getNavigationView(t=\"\",e,i=[],s=\"text\"){this.text=t,i.unshift(this.getActionButton());let n=new r;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(a.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(s)).navigationBarTitle(\"\"),n.setEvent(\"onPop\",()=>e(this.text)),n}}}),a(\"eSp9Z\",function(t,e){var i=n(\"gxpqj\"),s=i.L10n,a=i.Sheet,r=n(\"jVlss\").SecureFunction;class o{static build=-1;static today=0;static editor=1;static clipboard=2;static action=3;static keyboard=4;static recursion=5;static widget=6}class l{env;args;text;allText;section;uuid;selectedRange;selectedText;textBeforeInput;textAfterInput;editor;constructor({env:t,args:e,text:i,allText:s=null,section:n=null,uuid:a=null,selectedRange:r=null,selectedText:o=null,textBeforeInput:l=null,textAfterInput:h=null,editor:c=null}={}){this.env=t,this.args=e,this.text=i,this.allText=s??i,this.section=n,this.uuid=a,this.selectedRange=r,this.selectedText=o,this.textBeforeInput=l,this.textAfterInput=h,this.editor=c}}t.exports={ActionEnv:o,ActionData:l,Action:class{#b;secureFunction;constructor(t,e,i){this.#b=t,this.config=e,this.secureFunction=new r(this.#b,this.config),i.env===o.build&&((i=this.preview()).env=o.build),Object.assign(this,i),this.originalContent=String(this.text);let n=this.l10n();Object.keys(n).forEach(t=>{s.add(t,n[t])})}preview(){return new l({env:o.build})}l10n(){return{}}pageSheet({view:t,title:e=\"\",done:i,doneText:s=$l10n(\"DONE\"),rightButtons:n=[]}){new a().setView(t).addNavBar({title:e,popButton:{title:s,tapped:()=>{i&&i()}},rightButtons:n}).init().present()}quickLookImage(t){a.quickLookImage(t)}getAllClips(){return{favorite:this.#b.storage.all(\"favorite\").map(t=>t.text),clips:this.#b.storage.all(\"clips\").map(t=>t.text)}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replaceAll(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#b.storage.deleteTable(\"clips\"),!0}catch(t){throw this.#b.logger.error(t),t}}setContent(t){this.text=t,this.env===o.editor?this.editor.setContent(t):this.env===o.clipboard&&(this.#b.storage.updateText(this.section,this.uuid,t),this.#b.clips.updateList(!0))}getAction(t,e,i){let s=this.#b.actions.getActionDirByName(e);return this.#b.actions.getAction(t,s,i)}async runAction(t,e){let i=this.getAction(t,e,new l({env:o.recursion}));return await i.do()}async request(t,e,i,s){return this.secureFunction.http.request({url:t,method:e,body:i,header:s,timeout:3})}getUrls(){let t=this.text??\"\";return[...new Set([...t.match(/https?:\\/\\/[\\w-]+(\\.[\\w-]+)*([\\p{Script=Han}\\w.,@?^=%&:/~+#()\\-]*[\\w@?^=%&/~+#()\\-])?/giu)||[],...t.match(/\\b\\w+:\\/\\/[\\w-]+(\\.[\\w-]+)*([\\p{Script=Han}\\w.,@?^=%&:/~+#()\\-]*[\\w@?^=%&/~+#()\\-])?/giu)||[]])]}addinRun(t){$addin.run(t)}}}}),a(\"jVlss\",function(t,e){class i{#b;#v;notAllowed='\"The parameter or method is not allowed in Action.\"';constructor(t,e){if(this.#b=t,this.#v=JSON.parse(JSON.stringify(e)),!this.#v?.name||this.#v?.name===\"undefined\")throw Error(\"Cannot get Action name.\")}get name(){return this.#v.name}set name(t){let e=$l10n(\"ACTION_RESET_NAME_WARNING\").replaceAll(\"${name}\",this.name).replaceAll(\"${to_name}\",t);throw $ui.alert({title:$l10n(\"ACTION_SAFETY_WARNING\"),message:e}),Error(e)}info(t){this.#b.logger.info(t)}error(t){this.#b.logger.error(t)}}class s extends i{rootPath=this.notAllowed;extensions=this.notAllowed;read(){throw Error(this.notAllowed)}async download(){throw Error(this.notAllowed)}write(){throw Error(this.notAllowed)}delete(){throw Error(this.notAllowed)}list(){throw Error(this.notAllowed)}copy(){throw Error(this.notAllowed)}move(){throw Error(this.notAllowed)}mkdir(){throw Error(this.notAllowed)}exists(){throw Error(this.notAllowed)}isDirectory(){throw Error(this.notAllowed)}merge(){throw Error(this.notAllowed)}absolutePath(){throw Error(this.notAllowed)}}class n extends i{#T=\"ActionHttpPermission\";get #A(){return $cache.get(this.#T)||(this.#A={},{})}set #A(t={}){return $cache.set(this.#T,t)}async #E(){if(0===(await $ui.alert({title:$l10n(\"ACTION_PERMISSION_REQUEST\"),message:$l10n(\"ACTION_NETWORK_PERMISSION_MESSAGE\").replaceAll(\"${name}\",this.name),actions:[{title:$l10n(\"OK\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index){let t=this.#A;return t[this.name]=!0,this.#A=t,!0}return!1}async #S(){let t=this.#A;return\"boolean\"==typeof t[this.name]?t[this.name]:!!await this.#E()}async request(t={}){try{if(!await this.#S())throw Error(\"No network permission.\");this.info(`sending request [${t.method}]: ${t.url}`);let e=await $http.request(Object.assign({timeout:3},t));if(\"function\"==typeof t?.handler&&t?.handler(e),e.error)throw e.error;if(e?.response?.statusCode>=400){let t=e.data;throw\"object\"==typeof t&&(t=JSON.stringify(t)),Error(\"Http error: [\"+e.response.statusCode+\"] \"+t)}return e}catch(t){throw t.code&&(t=Error(\"Network error: [\"+t.code+\"] \"+t.localizedDescription)),this.error(`Action request error: ${this.name}`),this.error(t),t}}async get(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"GET\",await this.request(t)}async post(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"POST\",await this.request(t)}async download(){throw Error(this.notAllowed)}async upload(){throw Error(this.notAllowed)}async startServer(){throw Error(this.notAllowed)}async stopServer(){throw Error(this.notAllowed)}async shorten(t){return await $http.shorten(t)}async lengthen(t){return await $http.lengthen(t)}}t.exports={SecureFunction:class extends i{constructor(...t){super(...t),this.file=new s(...t),this.http=new n(...t)}addin(){throw Error(this.notAllowed)}},SecureScript:class{script;sf=\"this.secureFunction\";constructor(t){this.script=t}#I(t,e){this.script=this.script.replaceAll(t,e)}replaceEval(){this.#I(/\\$addin\\.*[a-zA-Z0-9\\[\\]'\"`]+/gi,`${this.sf}.addin()`),this.#I(\"eval\",`${this.sf}.addin()`)}replaceFile(){this.#I(\"$file\",`${this.sf}.file`)}replaceHttp(){this.#I(\"$http\",`${this.sf}.http`)}secure(){return this.replaceEval(),this.replaceFile(),this.replaceHttp(),this.script}}}}),a(\"a4uPv\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.Sheet,r=n(\"eSp9Z\"),o=r.ActionData,l=r.ActionEnv;t.exports=class{#x;menuItemActionMaxCount=5;placeholderReuseIdentifier=\"UITableViewPlaceholderReuseIdentifier\";constructor(t,e,i){this.kernel=t,this.data=e,this.views=i}initReuseIdentifier(t){if(!t.$dequeueReusableCellWithIdentifier(this.placeholderReuseIdentifier)){let e=$objc(\"UITableViewCell\").$class();t.$registerClass_forCellReuseIdentifier(e,this.placeholderReuseIdentifier)}}get listSelected(){let t=$(this.views.listId)?.ocValue()?.$indexPathsForSelectedRows()?.jsValue();return Array.isArray(t)?t:[]}get defaultMenuItems(){return[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(t,e)=>{let i=this.data.getByIndex(e);$input.text({placeholder:$l10n(\"ADD_TAG\"),text:i.tag,handler:t=>{(t=t.trim()).length>0?this.kernel.storage.setTag(i.uuid,t):this.kernel.storage.deleteTag(i.uuid),this.data.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(t,e)=>{let i=this.data.getByIndex(e);$share.sheet(i.image?i.imageOriginal:i.text)}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(t,e)=>this.data.copy(this.data.getByIndex(e).uuid)},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,items:[{title:$l10n(\"CONFIRM\"),destructive:!0,handler:(t,e)=>{t.delete(e),this.data.delete(this.data.getByIndex(e).uuid),$delay(.25,()=>t.reload())}}]}]}]}get menu(){let t=t=>{let e=this.kernel.actions.getActionHandler(t.category,t.dir);return t.handler=(t,i)=>{let s=this.data.getByIndex(i);e(new o({env:l.clipboard,text:s.text,section:s.section,uuid:s.uuid}))},t.title=t.name,t.symbol=t.icon,t},e=this.kernel.actions.getActions(\"clipboard\"),i={inline:!0,items:e.slice(0,this.menuItemActionMaxCount).map(t)};return e.length>this.menuItemActionMaxCount&&i.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:e.slice(this.menuItemActionMaxCount).map(t)}),{items:[i,...this.defaultMenuItems]}}setEditingCallback(t){this.#x=t}createUIMenu=({title:t,image:e,actions:i,inline:s=!1,destructive:n=!1}={})=>{let a;return s&&(a|=1),n&&(a|=2),$objc(\"UIMenu\").$menuWithTitle_image_identifier_options_children(t??\"\",e,null,a??0,i)};createUIAction=({title:t,image:e,handler:i,destructive:s=!1}={})=>{let n=$objc(\"UIAction\").$actionWithTitle_image_identifier_handler(t,e,null,$block(\"void, UIAction *\",t=>{i(t)}));return s&&n.$setAttributes(2),n};createUIContextualAction=({title:t,handler:e,color:i,image:s,destructive:n=!1}={})=>{let a=$objc(\"UIContextualAction\").$contextualActionWithStyle_title_handler(n?1:0,t,$block(\"void, UIContextualAction *, UIView *, block\",async(t,i,s)=>{s=t=>{t&&$(this.views.listId).ocValue().$setEditing_animated(!1,!0)},await e(t,i,s)}));return i&&a.$setBackgroundColor(i),s&&a.$setImage(s),a};createUITableViewDropPlaceholder(t){let e=$objc(\"UITableViewDropPlaceholder\").$alloc(),i=2*this.views.verticalMargin+this.views.getContentHeight(\"A\");return e.$initWithInsertionIndexPath_reuseIdentifier_rowHeight(t,this.placeholderReuseIdentifier,i),e}updateEditingToolBar(){let t=0===this.listSelected.length,e=$(this.views.editingToolBarId+\"-select-button\"),i=$(this.views.editingToolBarId+\"-delete-button\");e.title=t?$l10n(\"SELECT_ALL\"):$l10n(\"DESELECT_ALL\"),i.hidden=t}toggleAllSelected(t=!1,e=!0){let i=this.data.clips.length,s=$(this.views.listId).ocValue();if(t||0!==this.listSelected.length)for(let t=0;t{let t=this.listSelected.sort((t,e)=>t.rowthis.data.getByIndex(t).uuid);this.setEditing(!1),e.forEach(t=>this.data.delete(t)),t.forEach(t=>{$(this.views.listId).delete(t)})})}setEditing(t){let e=$(this.views.listId).ocValue(),i=void 0!==t?t:!e.$isEditing();if(i!==e.$isEditing()){if(e.$setEditing(i),\"function\"==typeof this.#x&&this.#x(i),i){let t=$ui.create(this.views.getListEditModeToolBarView({selectButtonEvents:{tapped:()=>this.toggleAllSelected()},deleteButtonEvents:{tapped:()=>this.deleteSelected()}}));$ui.window.add(t),$(this.views.editingToolBarId).layout((t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.views.editModeToolBarHeight)})}else $(this.views.editingToolBarId).remove()}}shouldBeginMultipleSelectionInteractionAtIndexPath(){return this.setEditing(!0),!0}didSelectRowAtIndexPath(t,e){if(t.$isEditing()){this.updateEditingToolBar();return}if(t.$hasActiveDrag())return;let i=this.data.getByIndex(e.jsValue());i.image?(a.quickLookImage(i.imageOriginal),t.$deselectRowAtIndexPath_animated(e,!0)):this.views.edit(i.text,s=>{t.$deselectRowAtIndexPath_animated(e,!0),i.text!==s&&this.data.update(s,i.uuid)})}didDeselectRowAtIndexPath(t,e){t.$isEditing()&&this.updateEditingToolBar()}contextMenuConfigurationForRowAtIndexPath(t,e,i){if(t.$isEditing())return;let s=i=>{let n=[];return i.items.forEach(i=>{i.items?n.push(s(i)):n.push(this.createUIAction({title:i.title,image:i.symbol,handler:()=>{i.handler(t.jsValue(),e.jsValue())},destructive:i.destructive}))}),this.createUIMenu({title:i.title,image:i.symbol,actions:n,inline:i.inline,destructive:i.destructive})};return $objc(\"UIContextMenuConfiguration\").$configurationWithIdentifier_previewProvider_actionProvider(null,null,$block(\"UIMenu *, NSArray *\",()=>s(this.menu)))}leadingSwipeActionsConfigurationForRowAtIndexPath(t,e){return $objc(\"UISwipeActionsConfiguration\").$configurationWithActions([this.createUIContextualAction({title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:async(t,i,s)=>{this.data.copy(this.data.getByIndex(e.jsValue()).uuid),s(!0)}})])}trailingSwipeActionsConfigurationForRowAtIndexPath(t,e){t=t.jsValue(),e=e.jsValue();let i=[this.createUIContextualAction({destructive:!0,title:$l10n(\"DELETE\"),handler:(i,s,n)=>{this.data.delete(this.data.getByIndex(e).uuid),t.delete(e),$delay(.25,()=>t.reload())}})];return 1===this.data.tabIndex&&i.push(this.createUIContextualAction({title:$l10n(\"FAVORITE\"),color:$color(\"orange\"),handler:(t,i,s)=>{this.data.favorite(e.row)}})),$objc(\"UISwipeActionsConfiguration\").$configurationWithActions(i)}heightForRowAtIndexPath(t,e){t=t.jsValue(),e=e.jsValue();let i=this.data.getByIndex(e),s=i?.hasTag?this.views.tagHeight:this.views.verticalMargin,n=i?.image?this.views.imageContentHeight:this.views.getContentHeight(i?.text??\"a\");return this.data.itemSize[e.row]=this.views.verticalMargin+n+s,this.data.itemSize[e.row]}delegate(){return $delegate({type:\"UITableViewDelegate\",events:{\"tableView:shouldBeginMultipleSelectionInteractionAtIndexPath:\":()=>this.shouldBeginMultipleSelectionInteractionAtIndexPath(),\"tableView:didBeginMultipleSelectionInteractionAtIndexPath:\":(t,e)=>{this.setEditing(!0)},\"tableView:didSelectRowAtIndexPath:\":(t,e)=>{this.didSelectRowAtIndexPath(t,e)},\"tableView:didDeselectRowAtIndexPath:\":(t,e)=>{this.didDeselectRowAtIndexPath(t,e)},\"tableView:contextMenuConfigurationForRowAtIndexPath:point:\":(t,e,i)=>this.contextMenuConfigurationForRowAtIndexPath(t,e,i),\"tableView:leadingSwipeActionsConfigurationForRowAtIndexPath:\":(t,e)=>this.leadingSwipeActionsConfigurationForRowAtIndexPath(t,e),\"tableView:trailingSwipeActionsConfigurationForRowAtIndexPath:\":(t,e)=>this.trailingSwipeActionsConfigurationForRowAtIndexPath(t,e),\"tableView:heightForRowAtIndexPath:\":(t,e)=>this.heightForRowAtIndexPath(t,e)}})}itemsForBeginningDragSession(t,e){let i=this.data.getByIndex(e.jsValue()),s=$objc(\"NSItemProvider\").$alloc();if(i.image){let t=$file.absolutePath(i.imagePath.original),e=NSURL.$fileURLWithPath(t);s.$initWithContentsOfURL(e)}else s.$initWithObject(i.text);let n=$objc(\"UIDragItem\").$alloc().$initWithItemProvider(s),a=t.$localContext();if(a)a.$addObject(n);else{let e=NSMutableArray.$new();e.$addObject(n),t.$setLocalContext(e)}return[n]}dragDelegate(){return $delegate({type:\"UITableViewDragDelegate\",events:{\"tableView:itemsForBeginningDragSession:atIndexPath:\":(t,e,i)=>this.itemsForBeginningDragSession(e,i)}})}reorder(t){let e=t.$items().$firstObject(),i=e.$sourceIndexPath().jsValue().row,s=t.$destinationIndexPath(),n=s.jsValue().row;this.data.moveItem(i,n),this.data.updateList(),t.$dropItem_toRowAtIndexPath(e.$dragItem(),s)}dropItems(t){let e=t.$destinationIndexPath();e||(e=$indexPath(0,0));let i=t.$items(),s=i.$count();for(let n=0;n{e&&($ui.alert(e.jsValue()),this.kernel.logger.error(e.jsValue()));try{h?this.data.addItem(t.jsValue().string,!1):c&&this.data.addItem(t.jsValue().image,!1),r.$commitInsertionWithDataSourceUpdates($block(\"void, NSIndexPath *\",t=>{this.data.moveItem(0,t.jsValue().row),this.data.updateList()}))}catch(t){return r.$deletePlaceholder(),$ui.warning(t),!1}};o.$loadDataRepresentationForTypeIdentifier_completionHandler(l[0],$block(\"void, NSData *, NSError *\",(t,e)=>{$delay(0,()=>d(t,e))}))}}dropDelegate(){return $delegate({type:\"UITableViewDropDelegate\",events:{\"tableView:canHandleDropSession:\":(t,e)=>!t.$isEditing(),\"tableView:dropSessionDidUpdate:withDestinationIndexPath:\":(t,e,i)=>{let s=$objc(\"UITableViewDropProposal\").$alloc();return e.$localDragSession()?s.$initWithDropOperation_intent(3,1):s.$initWithDropOperation_intent(2,1),s},\"tableView:performDropWithCoordinator:\":(t,e)=>{e.$session().$localDragSession()?this.reorder(e):this.dropItems(e)}}})}setDelegate(){let t=$(this.views.listId).ocValue();this.initReuseIdentifier(t),t.$setDelegate(this.delegate()),t.$setDragDelegate(this.dragDelegate()),t.$setDropDelegate(this.dropDelegate())}}}),a(\"gVMQa\",function(t,e){var i=n(\"gxpqj\"),s=i.NavigationView,a=i.Sheet,r=n(\"7TSVv\"),o=n(\"2VUvw\"),l=n(\"42nBp\"),h=n(\"kgD3J\"),c=n(\"r5Q7t\");t.exports=class extends r{collectionView;placeholderReuseIdentifier=\"UICollectionViewPlaceholderReuseIdentifier\";cellReuseIdentifier=\"ActionCollectionViewCellReuseIdentifier\";headerReuseIdentifier=\"ActionViewCustomHeaderReuseIdentifier\";footerReuseIdentifier=\"ActionViewCustomFooterReuseIdentifier\";constructor(...t){super(...t),this.views=new h(this.kernel,this),this.delegates=new c(this.kernel,this,this.views)}get actionList(){return super.actions.map(t=>{let e=[];return t.items.forEach(t=>{e.push(this.views.actionToData(t))}),{title:t.title,items:e}})}actionSyncStatus(){$app.listen({actionSyncStatus:t=>{if(t.status===o.status.syncing&&t.animate)this.updateNavButton(!0),this.updateSyncLabel($l10n(\"SYNCING\"));else if(t.status===o.status.success||t.status===o.status.nochange)try{this.applySnapshotAnimatingDifferences()}catch(t){this.kernel.logger.error(t),this.updateSyncLabel(t)}finally{this.updateSyncLabel(),this.updateNavButton(!1),this.collectionView.jsValue().endRefreshing()}}})}editActionInfoPageSheet(t,e){new l(this,t).editActionInfoPageSheet(e)}editActionMainJs(t=\"\",e){new l(this,e).editActionMainJs(t)}getNavButtons(){let t=[{title:$l10n(\"IMPORT_FROM_FILE\"),handler:async()=>{let t=await $drive.open();try{this.importAction(JSON.parse(t.string)),this.applySnapshotAnimatingDifferences()}catch(t){this.kernel.logger.error(t)}}}],e=[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,async t=>{let e=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(t,e);let i=this.getActionCategorySection(t.category);this.applySnapshotToSectionAnimatingDifferences(i),await $wait(.3),this.editActionMainJs(e,t)})}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>this.addActionCategory()},{inline:!0,items:t}];return[{symbol:\"plus.circle\",id:this.views.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:e}}]}updateSyncLabel(t){t||(t=$l10n(\"MODIFIED\")+this.getLocalSyncDate().toLocaleString()),$(this.views.syncLabelId)&&($(this.views.syncLabelId).text=t)}updateNavButton(t){let e=this.navigationView?.navigationBarItems?.getButton(this.views.addActionButtonId);e&&e.setLoading(t);let i=this.navigationView?.navigationBarItems?.getButton(this.views.sortActionButtonId);i&&i.setLoading(t);let s=this.navigationView?.navigationBarItems?.getButton(this.views.syncButtonId);s&&s.setLoading(t)}initReuseIdentifier(){this.collectionView.$registerClass_forCellWithReuseIdentifier($objc(\"UICollectionViewCell\").$class(),this.placeholderReuseIdentifier),this.collectionView.$registerClass_forCellWithReuseIdentifier($objc(\"UICollectionViewCell\").$class(),this.cellReuseIdentifier),this.views.actionViewCustomHeader(),this.collectionView.$registerClass_forSupplementaryViewOfKind_withReuseIdentifier($objc(\"ActionViewCustomHeader\").$class(),\"UICollectionElementKindSectionHeader\",this.headerReuseIdentifier),this.views.actionViewCustomFooter(),this.collectionView.$registerClass_forSupplementaryViewOfKind_withReuseIdentifier($objc(\"ActionViewCustomFooter\").$class(),\"UICollectionElementKindSectionFooter\",this.footerReuseIdentifier)}initDataSource(){let t=$block(\"UICollectionViewCell *, UICollectionView *, NSIndexPath *, id\",(t,e,i)=>{let s=t.$dequeueReusableCellWithReuseIdentifier_forIndexPath(this.cellReuseIdentifier,e);s.$contentView().$setClipsToBounds(!0),s.$contentView().$layer().$setCornerRadius(10);let{section:n,item:a}=e.jsValue(),r=this.views.matrixCell(this.actions[n].items[a]);return s.$contentView().jsValue().add(r),s}),e=$block(\"UICollectionReusableView *, UICollectionView *, NSString *, NSIndexPath *\",(t,e,i)=>{let{section:s}=i.jsValue();if(\"UICollectionElementKindSectionHeader\"!==e.jsValue())return t.$dequeueReusableSupplementaryViewOfKind_withReuseIdentifier_forIndexPath(e,this.footerReuseIdentifier,i);{let n=t.$dequeueReusableSupplementaryViewOfKind_withReuseIdentifier_forIndexPath(e,this.headerReuseIdentifier,i);return n.$titleLabel().$setText(this.actions[s].title),n}}),i=$objc(\"UICollectionViewDiffableDataSource\").$alloc();i.$initWithCollectionView_cellProvider(this.collectionView,t),i.$setSupplementaryViewProvider(e),$objc_retain(i)}applySnapshotUsingReloadData(){let t=$objc(\"NSDiffableDataSourceSnapshot\").$alloc().$init(),e=this.actions;for(let i in t.$appendSectionsWithIdentifiers(e.map(t=>t.dir)),e)t.$appendItemsWithIdentifiers_intoSectionWithIdentifier(e[i].items.map(t=>t.dir),e[i].dir);this.collectionView.$dataSource().$applySnapshotUsingReloadData(t)}applySnapshotAnimatingDifferences(t=!0){let e=$objc(\"NSDiffableDataSourceSnapshot\").$alloc().$init(),i=this.actions;for(let t in e.$appendSectionsWithIdentifiers(i.map(t=>t.dir+t.items.length)),i)e.$appendItemsWithIdentifiers_intoSectionWithIdentifier(i[t].items.map(t=>t.category+t.dir+t.name+t.icon),i[t].dir+i[t].items.length);this.collectionView.$dataSource().$applySnapshot_animatingDifferences(e,t)}applySnapshotToSectionAnimatingDifferences(t,e=!0){let i=$objc(\"NSDiffableDataSourceSectionSnapshot\").$alloc().$init(),{items:s,dir:n}=this.actions[t];n+=s.length,i.$appendItems(s.map(t=>t.category+t.dir+t.name+t.icon)),this.collectionView.$dataSource().$applySnapshot_toSection_animatingDifferences(i,n,e)}getMatrixView(){let t=this.views.getMatrixView({ready:t=>{this.collectionView=t.ocValue(),this.initReuseIdentifier(),this.delegates.setDelegate(),this.delegates.setRefreshControl(),this.initDataSource(),this.applySnapshotUsingReloadData()}});return this.actionSyncStatus(),t}getPage(){return this.navigationView=new s,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),this.navigationView.getPage()}present(){let t=new a,e=this.getNavButtons();t.setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:e}).init(),this.navigationView=t.navigationView,t.present()}}}),a(\"7TSVv\",function(t,e){var i=n(\"gxpqj\"),s=i.FileStorage,a=i.UIKit,r=n(\"eSp9Z\"),o=r.ActionEnv,l=r.ActionData,h=r.Action,c=n(\"jVlss\").SecureScript,d=n(\"7pN8M\"),u=n(\"2aNLD\").KeyboardPinActions,p=n(\"ilpYs\").TodayPinActions;t.exports=class{#C;#k;constructor(t){this.kernel=t,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+\"/sync.json\",this.checkUserAction(),this.initWebdavSync(),this.sync()}get actions(){return this.#C||this.#D(),this.#C}get allActions(){return this.#k||this.#D(),this.#k}get isNew(){return $cache.get(\"caio.action.isNew\")??!1}set isNew(t){$cache.get(\"caio.action.isNew\",t)}#D(){this.#C=this.getActionCategories().map(t=>({category:t,dir:t,title:this.getCategoryTitle(t),items:this.getActions(t)})),this.#k={},this.#C.map(t=>t.items.forEach(t=>{this.#k[t.name]=t})),this.kernel.logger.info(\"init actions\")}importExampleAction(){try{Object.keys(__ACTIONS__).forEach(t=>{Object.keys(__ACTIONS__[t]).forEach(e=>{let i=__ACTIONS__[t][e],s=JSON.parse(i.config);this.exists(s.name)||this.importAction(i,t,!1)})})}catch{$file.list(this.actionPath).forEach(t=>{let e=`${this.actionPath}/${t}`;if($file.isDirectory(e)){let i=`${this.userActionPath}/${t}`;$file.list(e).forEach(t=>{let s=JSON.parse($file.read(`${e}/${t}/config.json`).string);this.exists(s.name)||($file.mkdir(i),$file.copy({src:`${e}/${t}`,dst:`${i}/${t}`}))})}})}this.setNeedReload()}exportAction(t){let e=a.loading();e.start();let{category:i,dir:s,name:n}=t,r=this.actionToString(i,s);e.end(),$share.sheet([{name:n+\".json\",data:$data({string:r})}])}importAction(t,e=\"uncategorized\",i=!0){let n=i?a.loading():null;n?.start();try{let{config:i,main:n,readme:a}=t;if(!i||!n||!a)throw Error(\"Not an action\");let r=JSON.parse(i)?.name?.trim();if(!r||\"\"===r)throw Error(\"Not an action\");let o=this.initActionDirByName(r),l=this.getActionPath(e,o);return $file.mkdir(l),$file.write({data:$data({string:i}),path:s.join(l,\"config.json\")}),$file.write({data:$data({string:n}),path:s.join(l,\"main.js\")}),$file.write({data:$data({string:a}),path:s.join(l,\"README.md\")}),this.setNeedReload(!0),o}catch(t){throw t}finally{n?.end()}}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.isNew=!1,this.importExampleAction())}getLocalSyncDate(){return new Date(JSON.parse($file.read(this.localSyncFile)?.string??\"{}\").timestamp)}async initWebdavSync(){if(this.kernel.isWebdavEnabled)try{this.webdavSync=new d({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.logger.error(`${t}\n${t.stack}`),t}}setNeedReload(t){if(this.#C=void 0,this.#k=void 0,this.applySnapshotAnimatingDifferences(t),this.webdavSync)try{this.webdavSync.needUpload()}catch(t){$ui.alert({title:$l10n(\"ALERT\"),message:$l10n(\"WEBDAV_ERROR_CLOSED\")}),this.kernel.setting.set(\"webdav.status\",!1)}}async sync(){this.webdavSync&&this.webdavSync.sync()}updatePinActions(t,e){u.shared.setKernel(this.kernel).updateAction(t,e),p.shared.setKernel(this.kernel).updateAction(t,e)}actionToString(t,e){return JSON.stringify({config:this.getActionConfigString(t,e),main:this.getActionMainJs(t,e),readme:this.getActionReadme(t,e)})}defaultCategories(){return[\"uncategorized\",\"clipboard\",\"editor\"]}getActionCategories(){let t=this.defaultCategories();return t.concat($file.list(this.userActionPath).filter(e=>$file.isDirectory(`${this.userActionPath}/${e}`)&&0>t.indexOf(e)))}async deleteActionCategory(t){let e=`${this.userActionPath}/${t}`,i=await $ui.alert({title:$l10n(\"delete.category\").replace(\"${category}\",t),message:$l10n(\"delete.category.keep.actions\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]});if(2===i.index)return!1;if(0===i.index)for(let t of $file.list(e))$file.move({src:`${e}/${t}`,dst:`${this.userActionPath}/uncategorized/${t}`});return $file.delete(e),this.setNeedReload(),!0}addActionCategory(){$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:t=>{if(\"\"===(t=t.trim())){$ui.toast($l10n(\"INVALID_VALUE\"));return}let e=`${this.userActionPath}/${t}`;$file.isDirectory(e)&&$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")),$file.mkdir(e),$ui.success($l10n(\"SUCCESS\")),this.setNeedReload()}})}async renameActionCategory(t){let e=await $input.text({text:t});if(\"\"===(e=e.trim()))return $ui.toast($l10n(\"INVALID_VALUE\")),!1;let i=`${this.userActionPath}/${t}`,s=`${this.userActionPath}/${e}`;return $file.isDirectory(s)?($ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")),!1):($file.move({src:i,dst:s}),$ui.success($l10n(\"SUCCESS\")),this.setNeedReload(),!0)}getActionCategorySection(t){for(let e in this.actions)if(this.actions[e].dir===t)return e;return null}getActionOrder(t,e=!1){let i=`${this.userActionPath}/${t}`,s=`${i}/${this.actionOrderFile}`;if($file.exists(s)){let e=JSON.parse($file.read(s).string),n=e.filter(t=>!!$file.exists(`${i}/${t}`));return n.length!==e.length&&this.saveOrder(t,n),n}if(!e)return[];{let t=[];return $file.list(i).forEach(e=>{t.push(e)}),t}}getActionPath(t,e){return`${this.userActionPath}/${t}/${e}`}getActionConfigString(t,e){return $file.read(`${this.getActionPath(t,e)}/config.json`).string}getActionConfig(t,e){return JSON.parse(this.getActionConfigString(t,e))}getActionMainJs(t,e){return $file.read(`${this.getActionPath(t,e)}/main.js`).string}getActionReadme(t,e){return $file.read(`${this.getActionPath(t,e)}/README.md`).string}initActionDirByName(t){return $text.MD5(t)}getActionDirByName(t){return this.allActions[t].dir}getAction(t,e,i){$file.exists(this.getActionPath(t,e))||(e=this.initActionDirByName(e));try{let s=this.getActionMainJs(t,e),n=new c(s);return new(Function(\"Action\",\"ActionEnv\",\"ActionData\",`${n.secure()}\n return MyAction`)(h,o,l))(this.kernel,this.getActionConfig(t,e),i)}catch(t){throw this.kernel.logger.error(t),t}}getActionHandler(t,e){return async i=>{try{let s=this.getAction(t,e,i);return await s.do()}catch(t){throw this.kernel.logger.error(t),t}}}getActions(t){let e=[],i=`${this.userActionPath}/${t}`;if(!$file.exists(i))return[];let s=s=>{let n=`${i}/${s}/`;if($file.isDirectory(n)){let i=this.getActionConfig(t,s);e.push(Object.assign(i,{category:t,dir:s}))}},n=this.getActionOrder(t);return n.forEach(t=>s(t)),$file.list(i).forEach(t=>{-1===n.indexOf(t)&&s(t)}),e}getCategoryTitle(t){let e=t.toUpperCase(),i=$l10n(e);return i===e?t:i}#B(t,...e){let i;\"string\"!=typeof t&&(t=JSON.stringify(t));let n=s.join(this.userActionPath,...e),a=n.substring(0,n.lastIndexOf(\"/\"));$file.exists(a)||$file.mkdir(a);let r=$file.read(n)?.string;try{i=JSON.stringify(JSON.parse(r))}catch{i=r}t!==i&&$file.write({data:$data({string:t}),path:n})}changeCategory(t,e){$file.move({src:`${this.userActionPath}/${t.category}/${t.dir}`,dst:`${this.userActionPath}/${e.category}/${e.dir}`})}saveActionInfo(t,e){t&&(t.category!==e.category&&this.changeCategory(t,e),this.updatePinActions(t,e)),this.#B({icon:e.icon,color:e.color,name:e.name},e.category,e.dir,\"config.json\"),this.#B(e.readme,e.category,e.dir,\"README.md\"),this.setNeedReload(!0)}saveMainJs(t,e){this.#B(e,t.category,t.dir,\"main.js\"),this.setNeedReload()}saveOrder(t,e){this.#B(JSON.stringify(e),t,this.actionOrderFile),this.setNeedReload()}move(t,e){if(t.section===e.section&&t.item===e.item)return;let i=this.actions[t.section],s=i.items,n=i.dir,a=t=>t.map(t=>t.dir);if(t.section===e.section){let i=t.iteme.item?t.item+1:t.item;s.splice(i,0,s[t.item]),s=s.filter((t,e)=>e!==r),this.saveOrder(n,a(s))}else{let i=this.actions[e.section],r=i.items,o=i.dir;r.splice(e.item,0,s[t.item]),s=s.filter((e,i)=>i!==t.item);let l=r[e.item],h=Object.assign(JSON.parse(JSON.stringify(r[e.item])),{category:o});this.changeCategory(l,h),this.updatePinActions(l,h),this.saveOrder(o,a(r)),this.saveOrder(n,a(s))}this.setNeedReload()}delete(t){$file.delete(`${this.userActionPath}/${t.category}/${t.dir}`),this.setNeedReload(!0)}exists(t){return void 0!==this.allActions[t]}}}),a(\"7pN8M\",function(t,e){var i=n(\"gxpqj\").FileStorage,s=n(\"2VUvw\");class a extends s{localSyncDataPath=\"/user_action/sync.json\";webdavSyncDataPath=\"/sync.json\";tempPath=\"/temp\";webdavActionsPath=\"/actions.zip\";localActionsPath=\"/user_action\";constructor({host:t,user:e,password:s,basepath:n,kernel:a}={}){super({host:t,user:e,password:s,basepath:n=i.join(n,\"user_action\"),kernel:a})}async init(){await super.init(),this.sync()}isNew(){return this.kernel.actions.isNew}async pull(){let t=i.join(this.tempPath,\"user_action\"),e=this.kernel.fileStorage.filePath(t),s=await this.webdav.get(this.webdavActionsPath);if(!await $archiver.unzip({file:s.rawData,dest:e}))throw Error($l10n(\"UNZIP_FAILED\"));await this.downloadSyncData(),this.kernel.fileStorage.move(t,this.localActionsPath),this.kernel.logger.info(\"action webdav sync: pulled\")}async push(){let t=i.join(this.tempPath,\"actions.zip\");if(!$archiver.zip({directory:this.kernel.fileStorage.filePath(this.localActionsPath),dest:this.kernel.fileStorage.filePath(t)}))throw Error($l10n(\"ZIP_FAILED\"));await $wait(.5),await this.webdav.put(this.webdavActionsPath,this.kernel.fileStorage.readSync(t)),await this.uploadSyncData(),this.kernel.fileStorage.delete(t),this.kernel.logger.info(\"action webdav sync: pushed\")}notify(t){$app.notify({name:\"actionSyncStatus\",object:t})}async #u(){let t=!1;try{let e=await this.nextSyncStep();if(this.kernel.logger.info(`action nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else if(e===s.step.conflict){if(await this.conflict($l10n(\"ACTIONS\"))!==a.conflictKeep.webdav)return;t=!0}else{this.notify({status:s.status.nochange});return}this.notify({status:s.status.success,updateList:t})}catch(t){throw this.notify({status:s.status.fail,error:t}),t}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,()=>{this.#u(!0)})}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,()=>{this.updateLocalTimestamp(),this.#u()})}}t.exports=a}),a(\"2aNLD\",function(t,e){var i=n(\"gxpqj\").Sheet,s=n(\"3VDld\").SelectActions;class a{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){let t=$cache.get(\"keyboard.addins\");if(!t)return[];if($cache.get(\"keyboard.addins.all\")){let t=$addin.current.name;return $addin.list?.filter(e=>t!==e.displayName).map(t=>t.displayName)}try{return JSON.parse(t)}catch(t){return[]}}static setAddins(t=[]){t.map((e,i)=>{null===e&&t.splice(i,1)});try{$cache.set(\"keyboard.addins\",JSON.stringify(t))}catch(t){$cache.set(\"keyboard.addins\",void 0)}}static setAllAddins(t){$cache.set(\"keyboard.addins.all\",t)}getUnsetAddins(){let t=$addin.current.name,e=a.getAddins();return $addin.list?.filter(i=>e.indexOf(i.displayName)===-1&&t!==i.displayName).map(t=>t.displayName)}add(){let t={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(t,e,i)=>{let s=a.getAddins();s.unshift(i),a.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),t.delete(e)}},layout:$layout.fill};new i().setView(t).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:a.getAddins(),actions:[{title:\"delete\",handler:(t,e)=>{a.setAddins(t.data)}}]},events:{reorderFinished:t=>{a.setAddins(t)}},layout:$layout.fill}}async sheet(){if(0===(await $ui.menu({items:[$l10n(\"ALL_SCRIPTS\"),$l10n(\"SELECT_SCRIPTS\")]})).index)a.setAllAddins(!0);else{a.setAllAddins(!1);let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"DONE\")},rightButtons:this.getNavButtons()}),t.init().present()}}}class r extends s{static shared=new r;cacheKey=\"keyboard.pinAction\";constructor(t){super(t),this.listId=\"keyboard-pin-action-list\"}async sheet(){let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"PIN_ACTION\"),popButton:{title:$l10n(\"DONE\")},rightButtons:this.getNavButtons()}),t.init().present()}}t.exports={KeyboardAddins:a,KeyboardPinActions:r}}),a(\"3VDld\",function(t,e){var i=n(\"gxpqj\").Sheet;class s{static shared=new s;cacheKey;constructor(t){this.kernel=t}setKernel(t){return this.kernel=t,this}getActions(){let t=$cache.get(this.cacheKey);return Array.isArray(t)?t.filter(t=>this.kernel.actions.exists(t.name)):[]}addAction(t){let e=this.getActions();e.push(t),$cache.set(this.cacheKey,e)}setActions(t=[]){$cache.set(this.cacheKey,t)}updateAction(t,e){this.setActions(this.getActions().map(i=>i.category===t.category&&i.dir===t.dir?e:i))}add(){let t=\"keyboard.add.sheet\",e=()=>{let t=this.getActions().map(t=>t.name),e=this.kernel.actions.actionList;for(let i=0;i-1===t.indexOf(e.name.text));return e.map(t=>(t.rows=t.items,t)),e},s=this.kernel.actions.views.getActionListView((i,s)=>{this.addAction(s),$(this.listId).data=this.getListData(),$(t).data=e()},{id:t,bgcolor:$color(\"primarySurface\"),stickyHeader:!1,data:e()},{},$layout.fill);new i().setView(s).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListData(t=this.getActions()){return t.map(t=>this.kernel.actions.views.actionToData(t))}getListView(){return this.kernel.actions.views.getActionListView(void 0,{id:this.listId,bgcolor:$color(\"primarySurface\"),stickyHeader:!1,reorder:!0,data:this.getListData(),actions:[{title:\"delete\",handler:(t,e)=>{let i=t.data;this.setActions(i.map(t=>t.info.info))}}]},{reorderFinished:t=>{this.setActions(t.map(t=>t.info.info))}},$layout.fill)}async sheet(){let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"PIN_ACTION\"),popButton:{title:$l10n(\"DONE\")},rightButtons:this.getNavButtons()}),t.init().present()}}t.exports={SelectActions:s}}),a(\"ilpYs\",function(t,e){var i=n(\"gxpqj\").Sheet,s=n(\"3VDld\").SelectActions;class a extends s{static shared=new a;cacheKey=\"today.actions\";constructor(t){super(t),this.listId=\"today-action-list\"}sheet(){let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:this.getNavButtons()}),t.init().present()}}t.exports={TodayPinActions:a}}),a(\"42nBp\",function(t,e){var i=n(\"gxpqj\"),s=i.Setting,a=i.Sheet,r=n(\"f0nX9\"),o=n(\"eSp9Z\"),l=o.ActionEnv,h=o.ActionData;t.exports=class{editingActionInfo;constructor(t,e){this.data=t,this.info=e,this.raw=JSON.parse(JSON.stringify(e)),this.actionCategories=this.data.getActionCategories(),this.initEditingActionInfo(),this.initSettingInstance()}initEditingActionInfo(){this.isNew=!this.info,this.isNew?this.editingActionInfo={category:this.actionCategories[0],name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",readme:\"\"}:(this.editingActionInfo=this.info,this.editingActionInfo.readme=this.data.getActionReadme(this.info.category,this.info.dir))}initSettingInstance(){this.settingInstance=new s({structure:[],set:(t,e)=>(this.editingActionInfo[t]=e,!0),get:(t,e=null)=>Object.prototype.hasOwnProperty.call(this.editingActionInfo,t)?this.editingActionInfo[t]:e})}informationView(){let t=this.settingInstance.loader({setting:this.settingInstance,type:\"input\",key:\"name\",icon:[\"pencil.circle\",\"#FF3366\"],title:$l10n(\"NAME\")}).create(),e=this.settingInstance.loader({setting:this.settingInstance,type:\"color\",key:\"color\",icon:[\"pencil.tip.crop.circle\",\"#0066CC\"],title:$l10n(\"COLOR\")}).create();return[t,e,this.settingInstance.loader({setting:this.settingInstance,type:\"icon\",key:\"icon\",icon:[\"star.circle\",\"#FF9933\"],title:$l10n(\"ICON\"),bgcolor:this.data.views.getColor(this.editingActionInfo.color)}).create(),this.settingInstance.loader({setting:this.settingInstance,type:\"menu\",key:\"category\",icon:[\"tag.circle\",\"#33CC33\"],title:$l10n(\"CATEGORY\"),items:this.actionCategories,values:this.actionCategories,pullDown:!0}).create()]}actionInfoView(){let t={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,this.isNew?280:230)),$delay(.2,()=>t.focus())},didChange:t=>{this.editingActionInfo.readme=t.text}}}],layout:$layout.fill},e=[{title:$l10n(\"INFORMATION\"),rows:this.informationView()},{title:$l10n(\"DESCRIPTION\"),rows:[t]}];return{type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:e},layout:$layout.fill,events:{rowHeight:(t,e)=>1===e.section?120:50}}}editActionInfoPageSheet(t){let e=new a,i=async()=>{!(this.isNew&&(this.editingActionInfo.dir=this.data.initActionDirByName(this.editingActionInfo.name),this.data.exists(this.editingActionInfo.name)&&1===(await $ui.alert({title:$l10n(\"UNABLE_CREATE_ACTION\"),message:$l10n(\"ACTION_NAME_ALREADY_EXISTS\").replaceAll(\"${name}\",this.editingActionInfo.name)})).index))&&(e.dismiss(),this.data.saveActionInfo(this.raw,this.editingActionInfo),await $wait(.3),t&&t(this.editingActionInfo))};e.setView(this.actionInfoView()).addNavBar({title:\"\",popButton:{title:$l10n(\"CANCEL\")},rightButtons:[{title:$l10n(\"DONE\"),tapped:()=>i()}]}).init().present()}editorNavButtons(t){return[{symbol:\"book.circle\",tapped:()=>{let t=$file.read(\"scripts/action/README.md\")?.string;if(!t)try{t=__ACTION_README__.content}catch{}new a().setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).addNavBar({title:\"Document\",popButton:{symbol:\"x.circle\"}}).init().present()}},{symbol:\"play.circle\",tapped:async()=>{try{this.data.saveMainJs(this.info,t.text);let e=await this.data.getActionHandler(this.info.category,this.info.dir)(new h({env:l.build}));void 0!==e&&(\"object\"==typeof e&&(e=JSON.stringify(e,null,2)),new a().setView({type:\"code\",props:{lineNumbers:!0,editable:!1,text:e},layout:$layout.fill}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\")}}).init().present())}catch(t){this.data.kernel.logger.error(t)}}}]}editActionMainJs(t=\"\"){let e=new r(this.data.kernel);e.pageSheet(t,t=>{this.data.saveMainJs(this.info,t)},this.info.name,this.editorNavButtons(e),\"code\")}}}),a(\"kgD3J\",function(t,e){var i=n(\"gxpqj\"),s=i.BarButtonItem,a=i.UIKit;t.exports=class{addActionButtonId=\"action-manager-button-add\";sortActionButtonId=\"action-manager-button-sort\";syncButtonId=\"action-manager-button-sync\";syncLabelId=\"action-manager-sync-label\";editingToolBarId=\"action-editingToolBarId\";horizontalMargin=20;verticalMargin=14;editModeToolBarHeight=44;columns=2;spacing=15;itemHeight=100;headerHeight=35;constructor(t,e){this.kernel=t,this.data=e}getActionListView(t,e={},i={},s){return t&&(i.didSelect=(e,i,s)=>{let n=s.info.info;t(this.data.getActionHandler(n.category,n.dir),n)}),{type:\"list\",layout:(t,e)=>{\"function\"==typeof s?s(t,e):(t.top.width.equalTo(e.super.safeArea),t.bottom.inset(0))},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:(()=>{let t=this.data.actionList;return t.map(t=>(t.rows=t.items,t)),t})(),template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(15),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(20),t.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(t,e)=>{t.height.equalTo(30),t.centerY.equalTo(e.super),t.left.equalTo(e.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},e)}}getActionMiniView(t,e){return e||(e=[],this.data.actions.forEach(t=>{e=e.concat(t.items)})),{type:\"matrix\",props:{bgcolor:$color(\"clear\"),columns:2,itemHeight:50,spacing:8,data:e.map(t=>this.actionToData(t)),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.edges.equalTo(e.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:async(e,i,s)=>{let n=s.info.info,a=await t(n);this.data.getActionHandler(n.category,n.dir)(a)}}}}getMatrixEditModeToolBarView({selectButtonEvents:t,deleteButtonEvents:e}={}){return a.blurBox({id:this.editingToolBarId},[a.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.editingToolBarId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.inset(this.horizontalMargin),t.centerY.equalTo(e.super)},events:t},{type:\"button\",props:{id:this.editingToolBarId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(2*this.horizontalMargin),t.right.inset(this.horizontalMargin/2),t.centerY.equalTo(e.super)},events:e}],layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom)}}])}getColor(t,e=null){return t?\"string\"==typeof t?$color(t):$rgba(t.red,t.green,t.blue,t.alpha):e}actionToData(t){return{name:{text:t.name},icon:t?.icon?.slice(0,5)===\"icon_\"?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t?.icon)},color:{bgcolor:this.getColor(t.color)},info:{info:t}}}matrixCell(t){return{props:{bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{bgcolor:this.getColor(t.color),cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:Object.assign({tintColor:$color(\"#ffffff\")},t?.icon?.slice(0,5)===\"icon_\"?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t?.icon)}),layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:a.textColor,titleColor:a.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(s.style.iconSize)}}],events:{tapped:e=>{let i=this.data.getActionMainJs(t.category,t.dir);this.data.editActionMainJs(i,t)}},layout:t=>{t.top.right.inset(0),t.size.equalTo(s.style.width)}},{type:\"label\",props:{text:t.name,font:$font(16)},layout:(t,e)=>{t.bottom.left.inset(10),t.width.equalTo(e.super)}}],layout:$layout.fill}}actionViewCustomHeader(){$define({type:\"ActionViewCustomHeader: UICollectionReusableView\",props:[\"titleLabel\"],events:{\"initWithFrame:\":t=>{let e=(self=self.$super().$initWithFrame(t)).$bounds();e.x=this.spacing,e.y=this.headerHeight-21;let i=$objc(\"UILabel\").$alloc().$initWithFrame(e);return i.$setFont($font(\"bold\",21).ocValue()),i.$setTextAlignment($align.left),i.$setNumberOfLines(1),self.$setTitleLabel(i),self.$addSubview(self.$titleLabel()),self}}})}actionViewCustomFooter(){$define({type:\"ActionViewCustomFooter: UICollectionReusableView\",props:[\"titleLabel\"],events:{\"initWithFrame:\":t=>{let e=(self=self.$super().$initWithFrame(t)).$bounds();e.x=this.spacing;let i=$objc(\"UILabel\").$alloc().$initWithFrame(e);return i.$setFont($font(16).ocValue()),i.$setTextAlignment($align.left),self.$setTitleLabel(i),self.$addSubview(self.$titleLabel()),self}}})}collectionViewFlowLayout(){let t=$objc(\"UICollectionViewFlowLayout\").$alloc().$init();t.$setScrollDirection($scrollDirection.vertical),t.$setMinimumLineSpacing(this.spacing),t.$setMinimumInteritemSpacing(this.spacing);let e=$insets(this.spacing,this.spacing,0,this.spacing).ocValue();return t.$setSectionInset(e.$UIEdgeInsetsValue()),t}getMatrixView(t){return{type:\"matrix\",props:{bgcolor:a.scrollViewBackgroundColor},layout:$layout.fill,events:t}}}}),a(\"r5Q7t\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.Sheet,r=n(\"eSp9Z\"),o=r.ActionEnv,l=r.ActionData;t.exports=class{collectionView;#x;constructor(t,e,i){this.kernel=t,this.data=e,this.views=i}getActionByIndexPath(t){let e=t.$section(),i=t.$item();return this.data.actions[e].items[i]}get matrixSelected(){let t=this.collectionView?.$indexPathsForSelectedItems()?.jsValue();return Array.isArray(t)?t:[]}get menu(){return{items:[{title:$l10n(\"EDIT_DETAILS\"),symbol:\"slider.horizontal.3\",handler:(t,e,i)=>{this.data.editActionInfoPageSheet(i,t=>{this.data.applySnapshotToSectionAnimatingDifferences(e.$section())})}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(t,e,i)=>{let s=this.data.getActionMainJs(i.category,i.dir);this.data.editActionMainJs(s,i)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(t,e,i)=>{let s;try{s=__ACTIONS__[i.category][i.dir][\"README.md\"]}catch{s=this.data.getActionReadme(i.category,i.dir)}new a().setView({type:\"markdown\",props:{content:s},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(t,e,i)=>{this.data.exportAction(i)}},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(t,e,i)=>{s.deleteConfirm($l10n(\"DELETE_CONFIRM_MSG\"),()=>{this.data.delete(i),this.data.applySnapshotToSectionAnimatingDifferences(e.$section())})}}]}]}}setEditingCallback(t){this.#x=t}createUIMenu=({title:t,image:e,actions:i,inline:s=!1,destructive:n=!1}={})=>{let a;return s&&(a|=1),n&&(a|=2),$objc(\"UIMenu\").$menuWithTitle_image_identifier_options_children(t??\"\",e,null,a??0,i)};createUIAction=({title:t,image:e,handler:i,destructive:s=!1}={})=>{let n=$objc(\"UIAction\").$actionWithTitle_image_identifier_handler(t,e,null,$block(\"void, UIAction *\",t=>{i(t)}));return s&&n.$setAttributes(2),n};createUICollectionViewDropPlaceholder(t){let e=$objc(\"UICollectionViewDropPlaceholder\").$alloc();return e.$initWithInsertionIndexPath_reuseIdentifier(t,this.data.placeholderReuseIdentifier),e}updateEditingToolBar(){let t=0===this.matrixSelected.length,e=$(this.views.editingToolBarId+\"-select-button\"),i=$(this.views.editingToolBarId+\"-delete-button\");e.title=t?$l10n(\"SELECT_ALL\"):$l10n(\"DESELECT_ALL\"),i.hidden=t}toggleAllSelected(t=!1,e=!0){let i=this.data.clips.length;if(t||0!==this.matrixSelected.length)for(let t=0;t{this.matrixSelected.sort((t,e)=>t.itemthis.toggleAllSelected()},deleteButtonEvents:{tapped:()=>this.deleteSelected()}}));$ui.window.add(t),$(this.views.editingToolBarId).layout((t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.views.editModeToolBarHeight)})}else $(this.views.editingToolBarId).remove()}}didSelectItemAtIndexPath(t,e){if(t.$isEditing()){this.updateEditingToolBar();return}if(t.$hasActiveDrag())return;let i=this.getActionByIndexPath(e),s=new l({env:o.action,text:\"clipboard\"===i.category||\"uncategorized\"===i.category?$clipboard.text:null});this.data.getActionHandler(i.category,i.dir)(s)}didDeselectItemAtIndexPath(t,e){t.$isEditing()&&this.updateEditingToolBar()}contextMenuConfigurationForItemAtIndexPath(t,e,i){if(t.$isEditing())return;let s=i=>{let n=[];return i.items.forEach(i=>{i.items?n.push(s(i)):n.push(this.createUIAction({title:i.title,image:i.symbol,handler:()=>{i.handler(t,e,this.getActionByIndexPath(e))},destructive:i.destructive}))}),this.createUIMenu({title:i.title,image:i.symbol,actions:n,inline:i.inline,destructive:i.destructive})};return $objc(\"UIContextMenuConfiguration\").$configurationWithIdentifier_previewProvider_actionProvider(null,null,$block(\"UIMenu *, NSArray *\",()=>s(this.menu)))}scrollViewDelegate(){let t=this.data.navigationView.view.scrollableView.events;return{\"scrollViewDidScroll:\":e=>{t.didScroll(e.jsValue())},\"scrollViewDidEndDragging:willDecelerate:\":(e,i)=>{t.didEndDragging(e.jsValue(),i)},\"scrollViewDidEndDecelerating:\":e=>{t.didEndDecelerating(e.jsValue())},\"handleRefresh:\":async t=>{this.kernel.setting.get(\"webdav.status\")?this.data.sync():(this.data.applySnapshotAnimatingDifferences(),t.$endRefreshing())}}}setRefreshControl(){let t=$objc(\"UIRefreshControl\").$alloc().$init();if(t.$addTarget_action_forControlEvents(this.collectionView.$delegate(),\"handleRefresh:\",4096),this.kernel.setting.get(\"webdav.status\")){let e=$l10n(\"MODIFIED\")+this.data.getLocalSyncDate().toLocaleString(),i=$objc(\"NSAttributedString\").$alloc().$initWithString(e);t.$setAttributedTitle(i)}this.collectionView.$setRefreshControl(t)}delegate(){return $delegate({type:\"UICollectionViewDelegate, UICollectionViewDelegateFlowLayout\",events:{...this.scrollViewDelegate(),\"collectionView:shouldBeginMultipleSelectionInteractionAtIndexPath:\":(t,e)=>!1,\"collectionView:didSelectItemAtIndexPath:\":(t,e)=>{this.didSelectItemAtIndexPath(t,e)},\"collectionView:didDeselectItemAtIndexPath:\":(t,e)=>{this.didDeselectItemAtIndexPath(t,e)},\"collectionView:contextMenuConfigurationForItemsAtIndexPaths:point:\":(t,e,i)=>this.contextMenuConfigurationForItemAtIndexPath(t,e.$firstObject(),i),\"collectionView:contextMenuConfigurationForItemAtIndexPath:point:\":(t,e,i)=>this.contextMenuConfigurationForItemAtIndexPath(t,e,i),\"collectionView:layout:sizeForItemAtIndexPath:\":(t,e,i)=>{let s=this.views.spacing*(this.views.columns+1);return $size((t.$frame().width-s)/this.views.columns,this.views.itemHeight)},\"collectionView:layout:referenceSizeForHeaderInSection:\":(t,e,i)=>$size(t.$frame().width-2*this.views.spacing,this.views.headerHeight)}})}itemsForBeginningDragSession(t,e){let i=this.getActionByIndexPath(e),s=$objc(\"NSItemProvider\").$alloc().$init();s.$setSuggestedName(i.name+\".json\"),s.$registerDataRepresentationForTypeIdentifier_visibility_loadHandler(\"public.text\",0,$block(\"NSProgress *, block\",t=>(t($data({string:this.data.actionToString(i.category,i.dir)}).ocValue(),null),null)));let n=$objc(\"UIDragItem\").$alloc().$initWithItemProvider(s),a=t.$localContext();if(a)a.$addObject(n);else{let e=NSMutableArray.$new();e.$addObject(n),t.$setLocalContext(e)}return[n]}dragDelegate(){return $delegate({type:\"UICollectionViewDragDelegate\",events:{\"collectionView:itemsForBeginningDragSession:atIndexPath:\":(t,e,i)=>this.itemsForBeginningDragSession(e,i)}})}reorder(t){let e=t.$items().$firstObject(),i=e.$sourceIndexPath().jsValue(),s=t.$destinationIndexPath(),n=s.jsValue();this.data.move(i,n),this.data.applySnapshotAnimatingDifferences(!1),this.data.applySnapshotToSectionAnimatingDifferences(i.section),i.section!==n.section&&this.data.applySnapshotToSectionAnimatingDifferences(n.section),t.$dropItem_toItemAtIndexPath(e.$dragItem(),s)}dropItems(t){let e=t.$destinationIndexPath();if(!e)return;let i=t.$items(),s=i.$count();for(let n=0;n{e&&($ui.alert(e.jsValue()),this.kernel.logger.error(e.jsValue())),r.$commitInsertionWithDataSourceUpdates($block(\"void, NSIndexPath *\",e=>{let i;let s=(e=e.jsValue()).section,n=this.data.getActionCategories(),a=JSON.parse(t.jsValue().string),r=this.data.importAction(a,n[s]),o=this.data.actions[s].items;for(let t in o)if(o[t].dir===r){i=t;break}void 0!==i&&this.data.move($indexPath(s,i),e),this.data.applySnapshotToSectionAnimatingDifferences(s)}))};o.$loadDataRepresentationForTypeIdentifier_completionHandler(l[0],$block(\"void, NSData *, NSError *\",(t,e)=>{$delay(0,()=>h(t,e))}))}}dropDelegate(){return $delegate({type:\"UICollectionViewDropDelegate\",events:{\"collectionView:canHandleDropSession:\":(t,e)=>!t.$isEditing(),\"collectionView:dropSessionDidUpdate:withDestinationIndexPath:\":(t,e,i)=>{let s=$objc(\"UICollectionViewDropProposal\").$alloc();return e.$localDragSession()?s.$initWithDropOperation_intent(3,1):s.$initWithDropOperation_intent(2,1),s},\"collectionView:performDropWithCoordinator:\":(t,e)=>{e.$session().$localDragSession()?this.reorder(e):this.dropItems(e)}}})}setDelegate(){this.collectionView=this.data.collectionView,this.collectionView.$setDelegate(this.delegate()),this.collectionView.$setCollectionViewLayout(this.views.collectionViewFlowLayout()),this.collectionView.$setDragDelegate(this.dragDelegate()),this.collectionView.$setDropDelegate(this.dropDelegate())}}}),a(\"gYDdO\",function(t,e){let i=$app.info.bundleID.includes(\"taio\");class s{files=[];databases=[];actions={};constructor(t){this.kernel=t}deleteFiles(t){t.forEach(t=>{this.files.includes(t)||this.files.push(t)})}#O(){this.files.forEach(t=>{$file.exists(t)&&(this.kernel.logger.info(`delete file: ${t}`),$file.delete(t))})}rebuildDatabase(t,e){this.databases.push([t,e])}#R(){let t=(t,e)=>{let i=this.kernel.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"${t}\"`);if(null!==i.error)throw Error(`Code [${i.error.code}] ${i.error.domain} ${i.error.localizedDescription}`);i.result.next();let s=i.result.get(0);i.result.close(),s>0&&(this.kernel.logger.info(`copy data from old table: ${t}`),this.kernel.storage.sqlite.update(`INSERT INTO ${e} SELECT * FROM ${t}`),this.kernel.logger.info(`drop table: ${t}`),this.kernel.storage.sqlite.update(`DROP TABLE ${t}`))};this.databases.forEach(e=>{t(e[0],e[1])})}rebuildUserActions(t={}){for(let e of Object.keys(t))t[e].forEach(t=>{this.actions[e]||(this.actions[e]=[]),this.actions[e].includes(t)||this.actions[e].push(t)})}async #L(){if(0===Object.keys(this.actions).length)return;let t=\"scripts/action\",e=`${this.kernel.fileStorage.basePath}/user_action`,i=[];for(let e of Object.keys(this.actions))this.actions[e].forEach(s=>{let n;let a=`${t}/${e}/${s}/config.json`;$file.exists(a)?n=JSON.parse($file.read(`${t}/${e}/${s}/config.json`).string):n=__INFO__,i.push(n.name)});if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(i,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index){for(let i of Object.keys(this.actions))this.actions[i].forEach(s=>{$file.exists(`${e}/${i}/${s}`)&&(this.kernel.logger.info(`rebuild user action: ${i}/${s}`),$file.copy({src:`${t}/${i}/${s}/main.js`,dst:`${e}/${i}/${s}/main.js`}))});this.kernel.actions.setNeedReload()}}async do(){this.#O(),this.#R(),await this.#L()}}class n{version=13;userVersion=$cache.get(\"compatibility.version\")??0;constructor(t){this.kernel=t,this.compatibility=new s(this.kernel)}do(){if(this.userVersion>0&&this.userVersionthis.kernel.logger.error(t))}$cache.set(\"compatibility.version\",this.version)}call(t){if(\"function\"==typeof this[`ver${t}`])this[`ver${t}`]();else throw ReferenceError(`Version ${t} undefined`)}ver1(){this.compatibility.deleteFiles([\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),this.compatibility.rebuildDatabase(\"clipboard\",\"clips\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(this.kernel.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}ver2(){this.compatibility.deleteFiles([\"scripts/storage.js\",\"scripts/ui/clips-data.js\",\"scripts/ui/components/action-manager-data.js\"]),this.compatibility.rebuildDatabase(\"pin\",\"favorite\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\"]})}ver3(){this.compatibility.rebuildUserActions({clipboard:[\"SendToWin\"]})}ver4(){let t=\"/storage/user_action/data.json\";if($file.exists(t)){let e=JSON.parse($file.read(t).string).date;$file.write({data:$data({string:JSON.stringify({timestamp:e})}),path:\"/storage/user_action/sync.json\"}),$file.delete(t)}}ver5(){this.compatibility.rebuildUserActions({uncategorized:[\"DisplayClipboard\"]})}ver6(){this.compatibility.rebuildUserActions({clipboard:[\"GetFromWin\"]})}ver7(){this.compatibility.rebuildUserActions({uncategorized:[\"Replace\"]})}ver8(){}ver9(){this.compatibility.rebuildUserActions({clipboard:[\"SendToWin\"]})}ver10(){let t=this.kernel.fileStorage.basePath;$file.mkdir(t),$file.exists(\"storage\")&&$file.move({src:\"storage\",dst:t}),this.compatibility.deleteFiles([\"storage\"])}ver11(){this.kernel.storage.beginTransaction();try{[\"create table temp as select uuid, text, prev, next from clips where 1=1;\",\"drop table clips;\",\"alter table temp rename to clips;\",\"create table temp as select uuid, text, prev, next from favorite where 1=1;\",\"drop table favorite;\",\"alter table temp rename to favorite;\"].forEach(t=>this.kernel.storage.sqlite.update(t)),this.kernel.storage.commit()}catch(t){throw this.kernel.storage.rollback(),this.kernel.logger.error(t),t}}ver12(){i&&this.compatibility.deleteFiles([\"shared://caio\",\"storage\"])}ver13(){this.compatibility.deleteFiles([\"setting.json\",\"dist/CAIO-en.json\",\"dist/CAIO-zh-Hans.json\",\"dist/CAIO.js\",\"assets/icon\"])}}async function a(t){if(t)try{new n(t).do()}catch(e){throw t.logger.error(e),e}}t.exports=a}),a(\"iuWEe\",function(t,e){let i;var s=n(\"gxpqj\"),a=s.Kernel,r=s.UIKit,o=n(\"2aNLD\"),l=o.KeyboardAddins,h=o.KeyboardPinActions,c=n(\"23NnO\"),d=n(\"ilpYs\").TodayPinActions;t.exports=function(t){(i=t).setting.method.checkUpdate=async t=>{let e;t.start();let s=\"scripts/libs/easy-jsbox.js\";if($file.exists(s))try{let t=await i.checkUpdate();t&&($file.write({data:$data({string:t}),path:s}),$ui.toast(\"The framework has been updated.\"))}catch{}let n=await $http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\"}),r=n.data?.info.version;try{e=__INFO__}catch{e=JSON.parse($file.read(\"config.json\").string).info}a.versionCompare(r,e.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${r}\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),t.done()},i.setting.method.previewWidget=t=>{let{Widget:e}=n(\"gD12U\"),i={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach(t=>{i[t.name]=t.value})}catch(t){$ui.error(t);return}$ui.menu({items:Object.keys(i),handler:t=>{e.render(i[t])}})},i.setting.method.fileManager=()=>{i.fileManager.push(i.fileStorage.basePath)},function(){i.setting.method.exportClipboard=t=>{t.start(),i.storage.export(e=>{e?t.done():t.cancel()})},i.setting.method.importClipboard=t=>{t.start(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:e=>{if(void 0===e){t.cancel();return}\"db\"===e.fileName.slice(-2)||\"zip\"===e.fileName.slice(-3)?i.storage.import(e).then(()=>{t.done(),$delay(.3,()=>{$addin.restart()})}).catch(e=>{$ui.error(e),i.logger.error(e),t.cancel()}):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel())}})}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},i.setting.method.rebuildDatabase=t=>{t.start();let e=()=>{try{i.storage.rebuild(),t.done(),$delay(.8,()=>$addin.restart())}catch(e){t.cancel(),$ui.alert(e)}};$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{e()}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})},i.setting.method.deleteAllData=t=>{t.start(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{i.storage.deleteAllData(),t.done(),$delay(.5,()=>$addin.restart())}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})};let t=$text.uuid,e=()=>i.clips.getRecycleBin().map(t=>t?.text??\"None\");i.setting.method.recycleBin=()=>({type:\"list\",props:{id:t,data:e(),actions:[{title:\"delete\",handler:(t,e)=>{i.clips.removeFromRecycleBin(e.row)}}]},events:{didSelect:(t,e)=>{let s=i.clips.getRecycleBin()[e.row]??{};if(s.text){let n=i.clips.addItem(s.text);s.tag&&i.storage.setTag(n.uuid,s.tag),i.clips.removeFromRecycleBin(e.row),i.clips.updateList(!0),t.delete(e)}}},layout:$layout.fill}),i.setting.method.recycleBinNavButtons=()=>[{symbol:\"trash\",tapped:()=>{r.deleteConfirm($l10n(\"DELETE_TABLE\").replace(\"${table}\",$l10n(\"RECYCLE_BIN\")),()=>{i.clips.clearRecycleBin(),$(t).data=e()})}}]}(),i.setting.method.exportAction=t=>{t.start();let e=\"actions.zip\",s=`/${e}`,n=i.fileStorage.filePath(s);$archiver.zip({directory:i.actions.userActionPath,dest:n,handler:()=>{$share.sheet({items:[{name:e,data:$data({path:n})}],handler:e=>{e?t.done():t.cancel(),i.fileStorage.delete(s)}})}})},i.setting.method.importAction=t=>{t.start(),$drive.open({handler:e=>{if(void 0===e){t.cancel();return}if(\"zip\"===e.fileName.slice(-3)){let s=`${i.fileStorage.basePath}/action_import`;$archiver.unzip({file:e,dest:s,handler:()=>{$file.list(s).forEach(t=>{$file.isDirectory(`${s}/${t}`)&&$file.copy({src:`${s}/${t}`,dst:`${i.actions.userActionPath}/${t}`})}),$file.delete(s),t.done()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel()}})},i.setting.method.importExampleAction=t=>{t.start(),i.actions.importExampleAction(),t.done()},i.setting.method.rebuildAction=t=>{t.start(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_TITLE\"),message:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_MESSAGE\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(i.actions.userActionPath),i.actions.setNeedReload(),t.done(),$delay(.8,()=>$addin.restart())}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},i.setting.method.editCategory=()=>c.sheet(i),function(){let t=n(\"7eNYp\");i.setting.method.previewKeyboard=()=>{let e=new t(i),s=t=>{e.setKeyboardHeight(t),$(e.keyboardId).updateLayout(t=>{t.height.equalTo(e.keyboardHeight)}),1===e.keyboardDisplayMode&&$(e.keyboardId).get(e.views.listId).reload()},n=t=>(t-200)/200;return{views:[{type:\"label\",layout:(t,e)=>{t.top.inset(20),t.centerX.equalTo(e.super)},events:{ready:t=>t.text=e.keyboardHeight,tapped:t=>{$input.text({type:$kbType.number,text:e.keyboardHeight,handler:e=>{if(/^[0-9]+$/.test(e)){let i=Number(e);i=Math.max(i=Math.min(i,400),200),t.text=i,t.next.value=n(i),s(i)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.right.inset(20),t.width.equalTo(e.super).offset(-40)},events:{ready:t=>t.value=n(e.keyboardHeight),changed:t=>{let e=Math.floor(200*t.value+200);t.prev.text=e,s(e)}}},e.getView()],layout:(t,e)=>{t.left.right.bottom.equalTo(e.super.safeArea);let s=0;1===i.setting.get(\"mainUIDisplayMode\")&&(s=r.NavigationBarNormalHeight),t.top.equalTo(e.super.safeArea).inset(s)}}},i.setting.method.setKeyboardQuickStart=()=>{new l().sheet()},i.setting.method.keyboardPinAction=()=>{h.shared.setKernel(i).sheet()}}(),i.setting.method.previewTodayWidget=t=>{let e=new(n(\"49je6\"))(i).getView();r.push({views:[e]})},i.setting.method.setTodayWidgetActions=t=>{d.shared.setKernel(i).sheet()}}}),a(\"23NnO\",function(t,e){var i=n(\"gxpqj\").Sheet;class s{constructor(t){this.kernel=t,this.listId=\"action-category-list\"}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.kernel.actions.addActionCategory()}]}getActionCategories(){let t=this.kernel.actions.defaultCategories();return this.kernel.actions.getActionCategories().filter(e=>0>t.indexOf(e))}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!1,data:this.getActionCategories(),actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:async(t,e)=>{await this.kernel.actions.deleteActionCategory(t.object(e))&&t.delete(e)}}]},events:{didSelect:async(t,e,i)=>{await this.kernel.actions.renameActionCategory(i)&&(t.data=this.getActionCategories())}},layout:$layout.fill}}static async sheet(t){let e=new i,n=new s(t);e.setView(n.getListView()).addNavBar({title:$l10n(\"EDIT_CATEGORY\"),popButton:{title:$l10n(\"DONE\")},rightButtons:n.getNavButtons()}),e.init().present()}}t.exports=s}),a(\"7eNYp\",function(t,e){var i=n(\"eSp9Z\"),s=i.ActionData,a=i.ActionEnv,r=n(\"gxpqj\"),o=r.UIKit,l=r.Sheet,h=r.BarButtonItem,c=n(\"4c0o0\"),d=n(\"2aNLD\"),u=d.KeyboardAddins,p=d.KeyboardPinActions;class g extends c{static ReturnKeyType={UIReturnKeyDefault:0,UIReturnKeyGo:1,UIReturnKeyGoogle:2,UIReturnKeyJoin:3,UIReturnKeyNext:4,UIReturnKeyRoute:5,UIReturnKeySearch:6,UIReturnKeySend:7,UIReturnKeyYahoo:8,UIReturnKeyDone:9,UIReturnKeyEmergencyCall:10,UIReturnKeyContinue:11,UIReturnKeyJoining:12,UIReturnKeyRouteContinue:13};#N;keyboardId=\"keyboard.main\";actionsId=\"keyboard-list-actions\";keyboardSwitchLockId=\"keyboard-switch-lock\";keyboardSwitchLockKey=\"caio.keyboard.switch.lock\";keyboardReturnButton=\"keyboard-return-button\";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteTapticTimer=void 0;continuousDeleteDelay=.5;navHeight=50;keyboardFrameHeight=this.keyboardHeight;get isFullScreenIpad(){return!!$device.isIpad&&(this.isFullScreenIpadCacheTimer?.cancel(),this.isFullScreenIpadCacheTimer=$delay(.1,()=>{$cache.get(\"keyboard.isFullScreenIpad\")!==!o.isSplitScreenMode&&this.kernel.KeyboardRenderWithViewFunc(()=>this.getView()),$cache.set(\"keyboard.isFullScreenIpad\",!o.isSplitScreenMode)}),$cache.get(\"keyboard.isFullScreenIpad\")??!o.isSplitScreenMode)}get bottomBarHeight(){return this.isFullScreenIpad?90:50}get bottomButtonSize(){return $device.isIpad?this.isFullScreenIpad?{width:69,height:66}:{width:32,height:40}:{width:46,height:40}}get bottomButtonFontSize(){return this.isFullScreenIpad?20:16}get bottomButtonIconSize(){return this.isFullScreenIpad?26:16}get bottomButtonEdges(){return this.isFullScreenIpad?8:4}itemBackground=$color(\"#FFFFFF\",$rgba(151,151,151,.4));buttonBackground=$color($rgba(0,0,0,.15),$rgba(117,117,117,.4));constructor(t){super(t),this.keyboardDisplayMode=this.kernel.setting.get(\"keyboard.displayMode\"),this.backgroundImage=this.kernel.setting.get(\"keyboard.background.image\")?.image,this.useBlur=this.backgroundImage&&this.kernel.setting.get(\"keyboard.blur\"),this.deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\"),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1),this.views.listId+=\"keyboard\",this.views.scrollToOffsetDirectionX=this.keyboardDisplayMode,this.views.tabLeftMargin=10,this.views.horizontalMargin=15,this.views.verticalMargin=12,this.views.copiedIndicatorSize=5,this.views.containerMargin=this.isFullScreenIpad?12:4,this.views.fontSize=this.kernel.setting.get(\"keyboard.fontSize\"),this.views.tagHeight=this.views.verticalMargin+3,this.delegates.menuItemActionMaxCount=3,this.matrixBoxMargin=this.isFullScreenIpad?12:8,this.cornerRadius=this.isFullScreenIpad?8:5}get returnKeyLabel(){let t;switch($ui.controller.ocValue().$textDocumentProxy().$returnKeyType()){case g.ReturnKeyType.UIReturnKeyDefault:t=\"Return\";break;case g.ReturnKeyType.UIReturnKeyGo:t=\"Go\";break;case g.ReturnKeyType.UIReturnKeyGoogle:t=\"Google\";break;case g.ReturnKeyType.UIReturnKeyJoin:t=\"Join\";break;case g.ReturnKeyType.UIReturnKeyNext:t=\"Next\";break;case g.ReturnKeyType.UIReturnKeyRoute:t=\"Route\";break;case g.ReturnKeyType.UIReturnKeySearch:t=\"Search\";break;case g.ReturnKeyType.UIReturnKeySend:t=\"Send\";break;case g.ReturnKeyType.UIReturnKeyYahoo:t=\"Yahoo\";break;case g.ReturnKeyType.UIReturnKeyDone:t=\"Done\";break;case g.ReturnKeyType.UIReturnKeyEmergencyCall:t=\"Emergency Call\";break;case g.ReturnKeyType.UIReturnKeyContinue:t=\"Continue\";break;case g.ReturnKeyType.UIReturnKeyJoining:t=\"Joining\";break;case g.ReturnKeyType.UIReturnKeyRouteContinue:t=\"Route Continue\";break;default:t=\"Return\"}return $cache.set(\"keyboard.returnKeyLabel\",$l10n(t)),$l10n(t)}get returnKeyLabelCache(){return $cache.get(\"keyboard.returnKeyLabel\")??this.returnKeyLabel}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}get menu(){let t=this.delegates.menu.items;return{items:[t[0],t[2]]}}setKeyboardHeight(t){this.kernel.setting.set(\"keyboard.previewAndHeight\",t)}getKeyboardSwitchLock(){let t=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof t&&$cache.set(this.keyboardSwitchLockKey,!0),t}switchKeyboardSwitchLock(){let t=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!t),$(this.keyboardSwitchLockId).get(\"image\").symbol=t?\"lock.open\":\"lock\"}listReady(){if(0===this.keyboardDisplayMode)this.setDelegate();else{let t=$delegate({type:\"UICollectionViewDragDelegate\",events:{\"collectionView:itemsForBeginningDragSession:atIndexPath:\":(t,e,i)=>this.delegates.itemsForBeginningDragSession(e,i)}});$(this.views.listId).ocValue().$setDragDelegate(t)}this.updateList(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.readClipboard(),this.#N=$timer.schedule({interval:1,handler:()=>{if(!this.kernel.setting.get(\"clipboard.autoSave\")){this.#N.invalidate();return}this.readClipboard()}}))}keyboardTapped(t,e=!0){return async(...i)=>{if(e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.kernel.setting.get(\"keyboard.tapticEngineLevel\")),\"function\"==typeof t)try{await t(...i)}catch(t){throw this.kernel.logger.error(t),t}}}async getKeyboardActionData(){let t=$keyboard.selectedText;\"\"===t&&(t=null);let e=async()=>{let t=await $keyboard.getAllText();return\"\"===t&&(t=null),t};return new s({env:a.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:t??await e(),allText:await $keyboard.getAllText(),selectedText:t})}getTopButtonsView(){let t=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped(()=>$keyboard.dismiss())},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped(async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}})}];return t.push({symbol:\"bolt.circle\",tapped:this.keyboardTapped(()=>{let t=!0===$(this.actionsId).hidden;$(this.views.listId).hidden=t,$(this.actionsId).hidden=!t})}),p.shared.setKernel(this.kernel).getActions().forEach(e=>{let i=e?.icon?.slice(0,5)===\"icon_\"?$icon(e.icon.slice(5,e.icon.indexOf(\".\")),o.textColor):$image(e?.icon);t.push({symbol:i,tapped:this.keyboardTapped(async()=>{let t=await this.getKeyboardActionData();this.kernel.actions.getActionHandler(e.category,e.dir)(t)})})}),{type:\"view\",views:t.map(t=>{let e=new h;return e.buttonEdges=0,e.setAlign(o.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).definition}),layout:(e,i)=>{let s=new h;e.height.equalTo(i.super),e.right.inset(-s.edges),e.width.equalTo(s.width*t.length+s.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"image\",props:{image:$image(\"assets/icon.png\",\"assets/icon.white.png\")},events:{tapped:()=>this.kernel.openInJsbox(),ready:t=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:t,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(-2),t.size.equalTo($size(28,28))}}].concat(super.getTabView(),this.getTopButtonsView())}],layout:(t,e)=>{t.top.equalTo(e.super),t.left.equalTo(e.super.safeArea).offset(this.views.containerMargin),t.right.equalTo(e.super.safeArea).offset(-this.views.containerMargin),t.height.equalTo(this.navHeight)}}}#P(t,e){let i=this.bottomButtonSize,s=this.bottomButtonEdges,n=this.isFullScreenIpad?8:5,a=(n,a)=>{if(t.title){let e=Math.ceil($text.sizeThatFits({text:t.title,width:o.windowSize.width,font:$font(this.bottomButtonFontSize)}).width)+(s+12)*2;this.isFullScreenIpad&&(e=Math.max(1.5*i.height,e)),n.size.equalTo($size(e,i.height))}else n.size.equalTo(i);n.centerY.equalTo(a.super),a.prev&&a.prev.info.align===e?e===o.align.right?n.right.equalTo(a.prev.left).offset(-(1.5*s)):n.left.equalTo(a.prev.right).offset(1.5*s):e===o.align.right?n.right.inset(0):n.left.inset(0)},r={type:\"button\",props:Object.assign({smoothCorners:!1,cornerRadius:this.cornerRadius,id:t.id??$text.uuid,bgcolor:this.useBlur?$color(\"clear\"):this.buttonBackground,info:{align:e}},t.menu?{menu:t.menu}:{}),views:[{type:\"image\",props:{symbol:t.symbol,tintColor:o.textColor},layout:(t,i)=>{t.size.greaterThanOrEqualTo(this.bottomButtonIconSize),this.isFullScreenIpad?(t.bottom.inset(n),e===o.align.right?t.right.inset(n):t.left.inset(n)):t.center.equalTo(i.super)}},{type:\"label\",props:{text:t.title,font:$font(this.bottomButtonFontSize),color:o.textColor},layout:(t,i)=>{this.isFullScreenIpad?(t.bottom.inset(n),e===o.align.right?t.right.inset(n):t.left.inset(n)):t.center.equalTo(i.super)}}],events:Object.assign({},t.tapped?{tapped:t.tapped}:{},t.events),layout:$layout.fill};return this.useBlur?o.blurBox({info:{align:e},style:$blurStyle.ultraThinMaterial,smoothCorners:!1,cornerRadius:this.cornerRadius},[r],a):{type:\"view\",props:{info:{align:e}},views:[r],layout:a}}getBottomButtonsView(){let t=[],e=[];$ui.controller.ocValue().$needsInputModeSwitchKey()&&t.push({symbol:\"globe\",events:{ready:t=>{t.ocValue().$addTarget_action_forControlEvents($ui.controller.ocValue(),\"handleInputModeListFromView:withEvent:\",$UIEvent.allTouchEvents)}}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&t.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped(()=>this.switchKeyboardSwitchLock())}),t.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:u.getAddins().reverse().map(t=>({title:t,handler:this.keyboardTapped(()=>$addin.run(t))}))}}),e.push({title:this.returnKeyLabelCache,id:this.keyboardReturnButton,tapped:this.keyboardTapped(()=>$keyboard.send()),events:{ready:async()=>{await $wait(.2);let t=this.returnKeyLabel,e=this.#P({title:t},o.align.right).layout;$ui.animate({duration:.2,animation:()=>{$(this.keyboardReturnButton).super.updateLayout(e),$(this.keyboardReturnButton).super.relayout()},completion:()=>{$(this.keyboardReturnButton).get(\"label\").text=t}})}}},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped(async()=>{$keyboard.delete(),this.continuousDeleteTapticTimer=$delay(this.continuousDeleteDelay,()=>this.keyboardTapped()()),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:()=>$keyboard.delete()})})}),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.continuousDeleteTapticTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}});let i={type:\"button\",props:{smoothCorners:!1,cornerRadius:5,title:$l10n(\"SPACE\"),font:$font(16),bgcolor:this.itemBackground,titleColor:o.textColor},events:{tapped:this.keyboardTapped(()=>{$keyboard.insert(\" \")})},layout:(t,i)=>{let s=i.prev;for(let t=0;tthis.#P(t,o.align.left)),...e.map(t=>this.#P(t,o.align.right)),i]}getBottomBarView(){return{type:\"view\",views:this.getBottomButtonsView(),layout:(t,e)=>{t.bottom.equalTo(e.super.safeArea),t.left.equalTo(e.super.safeArea).offset(this.views.containerMargin),t.right.equalTo(e.super.safeArea).offset(-this.views.containerMargin),t.height.equalTo(this.bottomBarHeight)}}}itemContainer(t){return this.useBlur?o.blurBox({style:$blurStyle.ultraThinMaterial},t,$layout.fill):{type:\"view\",props:{bgcolor:this.itemBackground},views:t,layout:$layout.fill}}get matrixTemplate(){return{props:{smoothCorners:!0,cornerRadius:10},views:[this.itemContainer([{type:\"view\",props:{id:\"copied\",circular:this.views.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.size.equalTo(this.views.copiedIndicatorSize),t.left.top.inset(this.matrixBoxMargin/2)}},{type:\"label\",props:{id:\"content\",lines:0,font:$font(this.views.fontSize)},layout:(t,e)=>{t.top.left.right.equalTo(e.super).inset(this.matrixBoxMargin),t.height.lessThanOrEqualTo(e.super).offset(-(2*this.matrixBoxMargin)-this.views.tagHeight)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.left.right.equalTo(e.prev),t.height.equalTo(this.views.tagHeight),t.bottom.equalTo(e.super).inset(this.matrixBoxMargin)}}]),{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}get itemSelect(){return(t,e)=>{let i=this.clips[e.row];i.image?l.quickLookImage(i.imageOriginal):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())}}getMatrixView(){return{type:\"matrix\",props:{id:this.views.listId,bgcolor:$color(\"clear\"),menu:this.delegates.menu,direction:$scrollDirection.horizontal,alwaysBounceVertical:!1,alwaysBounceHorizontal:!0,showsHorizontalIndicator:!1,columns:1,spacing:this.matrixBoxMargin,template:this.matrixTemplate,backgroundView:$ui.create(this.views.getEmptyBackground())},layout:(t,e)=>{t.top.inset(0),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-1*(this.bottomBarHeight-this.navHeight))},events:{ready:()=>this.listReady(),didSelect:this.itemSelect,itemSize:(t,e)=>{let i=this.keyboardFrameHeight-this.navHeight-this.bottomBarHeight;return i-=2*this.matrixBoxMargin,this.itemSize[e.item]=i,$size(i,i)},layoutSubviews:t=>{let e=2*(this.navHeight+this.bottomBarHeight+this.matrixBoxMargin)-this.matrixBoxMargin+1,i=Math.max(t.frame.height,e);this.keyboardFrameHeight!==i&&(this.keyboardFrameHeight=i,t.reload())}}}}getListView(){let t=super.getListView();t.layout=(t,e)=>{t.top.equalTo(this.navHeight-1),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-this.bottomBarHeight-this.views.containerMargin)},this.delegates.didSelectRowAtIndexPath=(t,e)=>{t=t.jsValue(),e=e.jsValue(),this.itemSelect(t,e)},this.delegates.shouldBeginMultipleSelectionInteractionAtIndexPath=()=>!1,t.props.separatorColor=$color(\"lightGray\"),t.props.separatorInset=$insets(0,this.views.horizontalMargin,0,this.views.horizontalMargin),delete t.events.pulled,t.props.header={props:{height:1}},t.props.style=2;let e=t.props.template.views[0].views;return t.props.template.views[0]=this.itemContainer(e),t}getDataView(){return 0===this.keyboardDisplayMode?this.getListView():this.getMatrixView()}getActionView(){return{type:\"view\",props:{id:this.actionsId,hidden:!0},views:[this.kernel.actions.views.getActionMiniView(async()=>await this.getKeyboardActionData())],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.equalTo(this.views.containerMargin),t.right.equalTo(-this.views.containerMargin),t.bottom.equalTo(-this.bottomBarHeight)}}}getView(){let t={type:\"view\",views:[{type:\"image\",props:{image:this.backgroundImage},layout:$layout.fill},{type:\"view\",props:{bgcolor:$color(\"clear\",$rgba(0,0,0,.3))},layout:$layout.fill}],layout:$layout.fill};return{type:\"view\",props:{id:this.keyboardId},views:[this.backgroundImage?t:{},this.getDataView(),this.getTopBarView(),this.getBottomBarView(),this.getActionView()],layout:(t,e)=>{t.width.bottom.equalTo(e.super),t.height.equalTo(this.keyboardHeight)}}}}t.exports=g}),a(\"49je6\",function(t,e){var i=n(\"eSp9Z\"),s=i.ActionData,a=i.ActionEnv,r=n(\"gxpqj\"),o=r.View,l=r.UIKit,h=r.BarButtonItem,c=n(\"4c0o0\"),d=n(\"ilpYs\").TodayPinActions;class u extends c{actionsId=\"today-list-actions\";listContainerId=\"today-list-container\";readClipboardButtonId=\"today-nav-readClipboard\";pageIndexId=\"today-list-page-index\";navHeight=34;taptic=1;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(t){super(t),this.tabItems.push($l10n(\"ACTIONS\")),this.todayPinActions=new d(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.views.listId+=\"today\",this.views.tabLeftMargin=8,this.views.horizontalMargin=15,this.views.verticalMargin=5,this.views.copiedIndicatorSize=5,this.views.fontSize=14,this.views.tagHeight=12,this.views.tagColor=$color(\"gray\",\"lightGray\"),this.views.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(t){$cache.set(\"caio.today.tab.index\",t)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}get menu(){let t=this.delegates.defaultMenuItems.reverse();return t[0].items=t[0].items.reverse(),{items:t}}getByIndex(t){\"object\"==typeof t&&(t=t.row);let e=this.listPageSize*this.listPageNow[this.listSection];return t+=e,this.clips[t]}listReady(){$widget.modeChanged=t=>{this.setClipboarPageSize(t),this.isActionPage||this.updateList()},this.setClipboarPageSize($widget.mode),this.isActionPage||this.updateList(),this.appListen(),$delay(.5,()=>this.readClipboard())}async readClipboard(t=!1){this.isActionPage||$app.env!==$env.today||await super.readClipboard(t)}setClipboarPageSize(t){if(0===t)this.listPageSize=1;else{let t=(($app.env===$env.app?l.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.views.singleLineContentHeight+this.views.verticalMargin+Math.max(this.views.tagHeight,this.views.verticalMargin)),e=Math.floor(t);this.listPageSize=e,t-e>=.6&&this.listPageSize++}}buttonTapped(t,e=!0){return async(...i)=>{e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),await t(...i)}}switchTab(t){this.tabIndex=t,this.isActionPage?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=t,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){let t=[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped(async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}})}].map(t=>{let e=new h;return e.setAlign(l.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).setProps(t.props??{}),e.definition});return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.getTabView(),...t]}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomBarView(){let t=t=>({type:\"button\",props:{symbol:t===l.align.left?\"chevron.backward.circle\":\"chevron.forward.circle\",bgcolor:$color(\"clear\"),tintColor:l.textColor},layout:i=>{t===l.align.left?i.left.inset(this.views.horizontalMargin):i.right.inset(this.views.horizontalMargin),i.centerY.equalTo(e.super)},events:{tapped:this.buttonTapped(()=>{t===l.align.left?this.clipboardPrevPage():this.clipboardNextPage()})}}),e={type:\"view\",views:[t(l.align.left),t(l.align.right),{type:\"label\",props:{id:this.pageIndexId,align:$align.center,text:this.listPageNow[this.listSection]+1},layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.center.equalTo(e.super)}}],layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.navHeight)}};return e}delete(...t){super.delete(...t),this.updateList()}updateList(t=!1){t&&this.setNeedReload();let e=this.listPageNow[this.listSection]*this.listPageSize,i=e+this.listPageSize,s=this.clips;$(this.views.listId).data=s.slice(e,i).map(t=>this.views.lineData(t,this.copied.uuid===t.uuid));let n=this.listPageNow[this.listSection]+1,a=Math.ceil(s.length/this.listPageSize);$(this.pageIndexId).text=`${n}/${a}`}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){let t=Math.ceil(this.clips.length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(t,e)=>{let i=this.getByIndex(e),s=i.hasTag?this.views.tagHeight:this.views.verticalMargin,n=i.image?this.views.imageContentHeight:this.views.getContentHeight(i.text);return this.views.verticalMargin+n+s},didSelect:this.buttonTapped((t,e)=>{let i=this.getByIndex(e);i.image?$clipboard.image=i.imageOriginal:(this.setClipboardText(i.text),this.setCopied(i.uuid)),$ui.toast($l10n(\"COPIED\"))})},layout:(t,e)=>{t.top.width.equalTo(e.super),t.bottom.equalTo(e.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.bottom.left.right.equalTo(e.super.safeArea)}}}getActionView(){let t=this.todayPinActions.getActions();return 0===t.length&&(t=Object.values(this.kernel.actions.allActions)),{type:\"view\",props:{id:this.actionsId,hidden:!this.isActionPage},views:[this.kernel.actions.views.getActionMiniView(t=>new s({env:a.today,text:\"clipboard\"===t.category||\"uncategorized\"===t.category?$clipboard.text:null}),t)],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.right.bottom.equalTo(e.super.safeArea)}}}getView(){return o.create({props:{titleColor:l.textColor,barColor:l.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getActionView(),this.getListView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;let t=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{t.invalidate()}})}})}}})}}t.exports=u}),a(\"gD12U\",function(t,e){var i=n(\"gxpqj\").Logger,s=n(\"8Makm\").AppKernelBase;class a extends s{constructor(){super(),this.logger=new i,this.logger.printToFile(this.fileStorage,\"logs/widget.log\"),this.setting.setReadonly()}get isWebdavEnabled(){return!1}}class r{static kernel=new a;static widgetInstance(t,...e){if(!$file.exists(`/scripts/widget/${t}.js`))return!1;{let{Widget:i}=require(`./widget/${t}.js`);return new i(...e)}}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClips(){r.widgetInstance(\"Clips\",r.kernel).render()}static renderFavorite(){r.widgetInstance(\"Favorite\",r.kernel).render()}static renderActions(){r.widgetInstance(\"Actions\",r.kernel).render()}static render(t=$widget.inputValue??\"Actions\"){switch(t){case\"Clips\":r.renderClips();break;case\"Favorite\":r.renderFavorite();break;case\"Actions\":r.renderActions();break;default:r.renderError()}}}t.exports={Widget:r,run:()=>{r.render()}}}),a(\"ljE8b\",function(t,e){var i=n(\"8Makm\").AppKernelBase;class s extends i{constructor(){super(),this.setting.setReadonly()}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}}class a{static kernel=new s;static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();let t=new(n(\"7eNYp\"))(this.kernel);this.kernel.KeyboardRenderWithViewFunc(()=>t.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();let t=new(n(\"49je6\"))(this.kernel);this.kernel.UIRender(t.getView())}static shortcuts(){let t=$context.query.table?.trim()??\"\";if(\"\"!==t){let e=this.kernel.clips.tabItemsMap;this.kernel.clips.rememberTabIndex=!1,this.kernel.clips.tabIndex=e[t]??e.clips}try{if(void 0!==$context.query.set){let t=$context.query.set;if(\"\"===t.trim())throw Error(\"cannot set empty content\");this.kernel.clips.addItem(t),$intents.finish()}else if(void 0!==$context.query.get){let t=$context.query.get??0;if(\"number\"!=typeof t)throw Error(\"`get` must be a number index\");let e=this.kernel.clips.getByIndex(t);$intents.finish(e.text)}else $intents.finish(\"`get` or `set` is required\")}catch(t){$intents.finish(t.message)}finally{$intents.finish()}}}t.exports={run:()=>{$app.env===$env.today?a.renderTodayUI():$app.env===$env.keyboard?a.renderKeyboardUI():$app.env===$env.siri&&a.shortcuts()}}}),$app.strings={en:{AUTHOR:\"Author\",ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",RECYCLE_BIN:\"Recycle Bin\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",FAVORITE:\"Favorite\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from `${table}`?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",CATEGORY:\"Category\",EDIT_CATEGORY:\"Edit Category\",\"delete.category\":\"Delete Category ${category}\",\"delete.category.keep.actions\":\"Do you keep the actions in this category?\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM:\"Confirm\",DELETE_CONFIRM_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"Are you sure you want to rebuild?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"Rebuild also deletes the data saved in WebDAV Drive! (If enabled)\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",UNABLE_CREATE_ACTION:\"Unable to create action\",ACTION_NAME_ALREADY_EXISTS:\"Action `${name}` already exists\",IMPORT_FROM_FILE:\"Import from Files\",DEIT_CATEGORY:\"Edit Category\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",USE_BLUR:\"Use Blur\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_LEVEL:\"Taptic Engine Level\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",SPACE:\"Space\",ALL_SCRIPTS:\"All Scripts\",SELECT_SCRIPTS:\"Select Scripts\",FONT_SIZE:\"Font Size\",LIST:\"List\",MATRIX:\"Matrix\",PIN_ACTION:\"Pin Action\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\",EXPERIMENTAL:\"Experimental\",SYNC_ACTIONS:\"Sync Actions\",SYNCING:\"Syncing...\",LAST_SYNC_AT:\"Last sync at: \",MODIFIED:\"Modified: \",WEBDAV_ERROR_CLOSED:\"WebDAV sync has an error and is temporarily closed.\",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"A data synchronization conflict occurred\",DATA_CONFLICT_MESSAGE:\"Select the data you want to keep\",WEBDAV_DATA:\"WebDAV data\",LOCAL_DATA:\"Local data\",ADD_TO_TAIO:\"Add to Taio\",SELECT_TAIO_APP:\"Please select Taio App from the Share menu.\",ACTION_SAFETY_WARNING:\"Action safety warning\",ACTION_PERMISSION_REQUEST:\"Action permission request\",ACTION_RESET_NAME_WARNING:\"Action `${name}` is attempting to change its name to `${to_name}`, which may result in it gaining all permissions associated with `${to_name}`.\",ACTION_NETWORK_PERMISSION_MESSAGE:\"Would you like to grant Action `${name}` network permissions?\",Return:\"Return\",Go:\"Go\",Google:\"Google\",Join:\"Join\",Next:\"Next\",Route:\"Route\",Search:\"Search\",Send:\"Send\",Yahoo:\"Yahoo\",Done:\"Done\",\"Emergency Call\":\"Emergency Call\",Continue:\"Continue\",Joining:\"Joining\",\"Route Continue\":\"Route Continue\"},\"zh-Hans\":{AUTHOR:\"作者\",ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在 iPhone 上复制某些内容,然后使用 iCloud 将其粘贴到 Mac 上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",RECYCLE_BIN:\"回收站\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",FAVORITE:\"收藏\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除 `${table}` 的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",CATEGORY:\"分类\",EDIT_CATEGORY:\"编辑分类\",\"delete.category\":\"删除分类 ${category}\",\"delete.category.keep.actions\":\"是否保留该分类中的动作?\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM:\"确认\",DELETE_CONFIRM_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"您确认要重建?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"重建会同时删除保存在 WebDAV 中的数据!(如果开启的话)\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",UNABLE_CREATE_ACTION:\"无法创建动作\",ACTION_NAME_ALREADY_EXISTS:\"动作 `${name}` 已存在\",IMPORT_FROM_FILE:\"从文件导入\",DEIT_CATEGORY:\"编辑分类\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",USE_BLUR:\"使用模糊效果\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_LEVEL:\"触感反馈强度\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",SPACE:\"空格\",ALL_SCRIPTS:\"所有脚本\",SELECT_SCRIPTS:\"选择脚本\",FONT_SIZE:\"字体大小\",LIST:\"列表\",MATRIX:\"网格\",PIN_ACTION:\"置顶动作\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\",EXPERIMENTAL:\"实验功能\",SYNC_ACTIONS:\"动作同步\",SYNCING:\"正在同步...\",LAST_SYNC_AT:\"最后同步:\",MODIFIED:\"最近修改:\",WEBDAV_ERROR_CLOSED:\"WebDAV 同步出错,暂时关闭。\",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"数据同步发生冲突\",DATA_CONFLICT_MESSAGE:\"请选择想要保留的数据\",WEBDAV_DATA:\"WebDAV 数据\",LOCAL_DATA:\"本地数据\",ADD_TO_TAIO:\"添加到 Taio\",SELECT_TAIO_APP:\"请在分享菜单中选择 Taio App\",ACTION_SAFETY_WARNING:\"动作安全警告\",ACTION_PERMISSION_REQUEST:\"动作权限申请\",ACTION_RESET_NAME_WARNING:\"动作 `${name}` 正在尝试将名称改为 `${to_name}`,这可能导致其获取 `${to_name}` 的所有权限\",ACTION_NETWORK_PERMISSION_MESSAGE:\"是否允许动作 `${name}` 获取网络权限?\",Return:\"返回\",Go:\"前往\",Google:\"谷歌\",Join:\"加入\",Next:\"下一步\",Route:\"路线\",Search:\"搜索\",Send:\"发送\",Yahoo:\"雅虎\",Done:\"完成\",\"Emergency Call\":\"紧急呼叫\",Continue:\"继续\",Joining:\"正在加入\",\"Route Continue\":\"继续路线\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"2.2.13\",author:\"ipuppet\",module:!1},__README__={\"README.md\":'# CAIO\\r\\n\\r\\n> Clipboard all in one. \\r\\n> An iOS clipboard tool based on JSBox.\\r\\n\\r\\n[See My Blog](https://blog.ultagic.com/#/detail/42/)\\r\\n\\r\\nSupport for home widgets and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nThe build script depends on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO.json](./dist/CAIO.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data differences in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> Sync data with WebDAV.\\r\\n\\r\\nConfig Example: \\r\\nHost: `https://example.com/dav` \\r\\nUser: `guest` \\r\\nPassword: `password123` \\r\\nBase Path: `/path/to/save`\\r\\n\\r\\n## Shortcuts\\r\\n\\r\\nPlease add a new action called `Run JSBox script` and set the `Name` parameter to `CAIO`.\\r\\n\\r\\nNext, set the `Parameter Dictionary` to a `Dictionary`.\\r\\n\\r\\n| Parameter | Type |\\r\\n| --------- | ------ |\\r\\n| set | Text |\\r\\n| get | Number |\\r\\n| table | Text |\\r\\n\\r\\n- `set`: The content will be saved to CAIO unless there is already an existing item with the same name.\\r\\n- `get`: The item at the specified index (e.g., 0) will be returned.\\r\\n- `table`: It will specify the table to either set or get the item from, with options being `[\"favorite\", \"clips\"]`. This parameter is optional and has a default value of `clips`.\\r\\n',\"README_CN.md\":'# CAIO\\r\\n\\r\\n> Clipboard all in one. \\r\\n> An iOS clipboard tool based on JSBox.\\r\\n\\r\\n[查看我的博客](https://blog.ultagic.com/#/detail/42/)\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO.json](./dist/CAIO.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> 通过 WebDAV 同步数据\\r\\n\\r\\n示例配置: \\r\\nHost: `https://example.com/dav` \\r\\nUser: `guest` \\r\\nPassword: `password123` \\r\\nBase Path: `/path/to/save`\\r\\n\\r\\n## 快捷指令\\r\\n\\r\\n添加一个名为 `运行 JSBox 脚本` 的动作,并将 `脚本名` 参数设置为 `CAIO`。\\r\\n\\r\\n然后将 `参数词典` 设置为一个 `字典`。\\r\\n\\r\\n| 参数 | 类型 |\\r\\n| ----- | ------ |\\r\\n| set | Text |\\r\\n| get | Number |\\r\\n| table | Text |\\r\\n\\r\\n- `set`:将把内容保存到CAIO中,除非已存在相同名称的项。\\r\\n- `get`:将返回指定索引(例如:0)处的项。\\r\\n- `table`:将指定要设置或获取项的表格,可选项为 `[\"favorite\", \"clips\"]`。此项可省略,默认值为 `clips`。\\r\\n'},__ACTIONS__={clipboard:{B23Clean:{config:'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"b23 清除追踪\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"b23clean.converting\": \"正在转换...\",\\n \"b23clean.noUrl\": \"未检测到链接\",\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\n \"b23clean.noChange\": \"无变化\",\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\n },\\n en: {\\n \"b23clean.converting\": \"Converting...\",\\n \"b23clean.noUrl\": \"No link detected\",\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\n \"b23clean.success\": \"Converted to BV video link\",\\n \"b23clean.noChange\": \"No change\",\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\n }\\n }\\n }\\n\\n async cleanUrl(b23url) {\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n }\\n\\n let url = b23url\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\n const resp = await $http.get(b23url)\\n url = resp.response.url\\n }\\n\\n const queryStart = url.indexOf(\"?\")\\n if (queryStart > -1) {\\n url = url.substring(0, queryStart - 1)\\n }\\n\\n return url\\n }\\n\\n /**\\n * 系统会调用 do() 方法\\n */\\n async do() {\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\n\\n try {\\n const b23url = this.getUrls()\\n if (b23url.length === 0) {\\n throw new Error($l10n(\"b23clean.noUrl\"))\\n }\\n\\n if (b23url.length === 1) {\\n let url = await this.cleanUrl(b23url[0])\\n $ui.clearToast()\\n $ui.alert({\\n title: $l10n(\"b23clean.success\"),\\n message: url,\\n actions: [\\n { title: $l10n(\"OK\") },\\n {\\n title: $l10n(\"COPY\"),\\n handler: () => {\\n $clipboard.text = url\\n $ui.success($l10n(\"COPIED\"))\\n }\\n }\\n ]\\n })\\n } else {\\n if (this.env !== ActionEnv.editor) {\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\n return\\n }\\n let flag = false\\n for (let i = 0; i < b23url.length; i++) {\\n try {\\n const url = b23url[i].trim()\\n const replacedUrl = await this.cleanUrl(url)\\n flag = true\\n\\n if (url !== replacedUrl) {\\n const newText = this.text.replace(url, replacedUrl)\\n this.setContent(newText)\\n }\\n } catch {}\\n }\\n if (!flag) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n } else {\\n $ui.toast($l10n(\"b23clean.noChange\"))\\n }\\n }\\n } catch (error) {\\n $ui.clearToast()\\n $delay(0.5, () => $ui.error(error))\\n }\\n }\\n}\\n',readme:\"## B23Clean\\n\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{config:'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"清除剪切板\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"clipboard.clean.success\": \"剪切板已清空\"\\n },\\n en: {\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\n }\\n }\\n }\\n\\n /**\\n * 系统会调用 do() 方法\\n */\\n do() {\\n $clipboard.clear()\\n $ui.success($l10n(\"clipboard.clean.success\"))\\n }\\n}\\n',readme:\"## CleanClipboard\\n\\n清空当前剪切板内容。\"},DownloadFromUrl:{config:'{\\n \"icon\": \"square.and.arrow.down\",\\n \"color\": \"#FF0099\",\\n \"name\": \"从链接下载\"\\n}',main:'class MyAction extends Action {\\n async downloadContent(url) {\\n const response = await $http.get({\\n url,\\n showsProgress: true\\n })\\n if (response.error) {\\n $ui.alert(response.error.localizedDescription)\\n } else {\\n return response\\n }\\n }\\n\\n async do() {\\n const url = this.getUrls()\\n let response = undefined\\n if (url.length > 1) {\\n $ui.menu({\\n items: url,\\n handler: async (title, index) => {\\n response = await this.downloadContent(url[index])\\n }\\n })\\n } else if (url.length === 1) {\\n response = await this.downloadContent(url[0])\\n } else {\\n $ui.warning(\"未检测到链接\")\\n return\\n }\\n $share.sheet([\\n {\\n name: response.response.suggestedFilename,\\n data: response.data\\n }\\n ])\\n return response\\n }\\n}\\n',readme:\"## DownloadFromUrl\\n\\n从链接下载内容,如 js 文件内容等。\"},GetFromWin:{config:'{\\n \"icon\": \"square.and.arrow.down\",\\n \"color\": \"#33CC33\",\\n \"name\": \"读取 clipsync\"\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n if ($app.env === $env.keyboard) {\\r\\n $keyboard.insert(resp.data.data)\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## GetFromWin\\n\\n通 clipsync 读取 PC 剪切板。\\n\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\n\"},OpenUrl:{config:'{\\n \"icon\": \"link\",\\n \"color\": \"#FF0099\",\\n \"name\": \"打开链接\"\\n}',main:'class MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"openLink.nourl\": \"未检测到链接\"\\n },\\n en: {\\n \"openLink.nourl\": \"No link detected\"\\n }\\n }\\n }\\n\\n openUrl(url) {\\n $app.openURL(url.trim())\\n }\\n\\n do() {\\n const url = this.getUrls()\\n if (url.length > 1) {\\n $ui.menu({\\n items: url,\\n handler: (title, index) => {\\n this.openUrl(url[index])\\n }\\n })\\n } else if (url.length === 1) {\\n this.openUrl(url[0])\\n } else {\\n $ui.warning($l10n(\"openLink.nourl\"))\\n }\\n }\\n}\\n',readme:\"## OpenUrl\\n\\n提取文本中的URL并打开。\"},RawRepoConverter:{config:'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"RawRepoConverter\"\\r\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n #component\\r\\n\\r\\n get component() {\\r\\n if (!this.#component) {\\r\\n const url = String(this.text)\\r\\n const path = url.substring(url.indexOf(\"/\", \"https://\".length) + 1)\\r\\n this.#component = path.split(\"/\")\\r\\n }\\r\\n return this.#component\\r\\n }\\r\\n\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n githubusercontent() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n branch = this.component[2],\\r\\n file = this.component.slice(3).join(\"/\")\\r\\n return `https://github.com/${user}/${repository}/blob/${branch}/${file}`\\r\\n }\\r\\n\\r\\n github() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n blob = this.component[2],\\r\\n branch = this.component[3],\\r\\n file = this.component.slice(4).join(\"/\")\\r\\n return `https://raw.githubusercontent.com/${user}/${repository}/${branch}/${file}`\\r\\n }\\r\\n\\r\\n do() {\\r\\n let result\\r\\n const url = String(this.text)\\r\\n if (url.includes(\"raw.githubusercontent.com\")) {\\r\\n result = this.githubusercontent(url)\\r\\n } else if (url.includes(\"github.com\")) {\\r\\n if (url.includes(\"?raw=true\")) {\\r\\n result = url.replace(\"?raw=true\", \"\")\\r\\n } else {\\r\\n result = this.github()\\r\\n }\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n return\\r\\n }\\r\\n\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n $clipboard.text = result\\r\\n }\\r\\n}\\r\\n',readme:\"## RawRepoConverter\\r\\n\\r\\nGithub Raw 链接和 Repository 链接转换器\\r\\n\"},SendToWin:{config:'{\\n \"icon\": \"square.and.arrow.up\",\\n \"color\": \"#33CC33\",\\n \"name\": \"推送 clipsync\"\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: this.text ?? $clipboard.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## SendToWin\\n\\n通 clipsync 推送剪切板至 PC。\\n\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\n\"},Tokenize:{config:'{\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\n \"color\": \"#0099FF\",\\n \"name\": \"分词复制\"\\n}',main:'class MyAction extends Action {\\n getView() {\\n const color = {\\n background: {\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\n },\\n text: {\\n normal: $color(\"##074FF\", \"##074FF\"),\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\n }\\n }\\n const fontSize = 16\\n const edges = 10\\n return {\\n type: \"matrix\",\\n layout: $layout.fill,\\n props: {\\n spacing: edges,\\n data: this.results.map(item => ({ label: { text: item } })),\\n template: {\\n views: [{\\n type: \"label\",\\n props: {\\n id: \"label\",\\n align: $align.center,\\n cornerRadius: edges,\\n bgcolor: color.background.normal,\\n font: $font(fontSize),\\n textColor: color.text.normal\\n },\\n layout: $layout.fill\\n }]\\n }\\n },\\n events: {\\n highlighted: () => { },\\n itemSize: (sender, indexPath) => {\\n const width = fontSize * this.results[indexPath.item].length + 1\\n if (this.maxtrixItemHeight === undefined)\\n this.maxtrixItemHeight = fontSize + edges * 2\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\n },\\n didSelect: (sender, indexPath) => {\\n const index = this.selected.indexOf(indexPath.item)\\n const label = sender.cell(indexPath).get(\"label\")\\n if (index === -1) {\\n this.selected.push(indexPath.item)\\n label.bgcolor = color.background.highlight\\n label.textColor = color.text.highlight\\n } else {\\n this.selected.splice(index, 1)\\n label.bgcolor = color.background.normal\\n label.textColor = color.text.normal\\n }\\n }\\n }\\n }\\n }\\n /**\\n * 系统会调用 do() 方法\\n */\\n do() {\\n this.selected = []\\n this.results = []\\n $text.tokenize({\\n text: this.text,\\n handler: results => {\\n this.results = results\\n this.pageSheet({\\n view: this.getView(),\\n done: () => {\\n const result = []\\n this.selected.sort().forEach(i => {\\n result.push(this.results[i])\\n })\\n if (result.length > 0) {\\n const text = result.join(\"\")\\n $clipboard.text = text\\n $ui.alert({\\n title: \"完成\",\\n message: `已复制内容:${text}`\\n })\\n }\\n }\\n })\\n }\\n })\\n }\\n}\\n',readme:\"## Tokenize\\n\\n将文本分词处理后复制。\"}},editor:{Paste:{config:'{\\n \"icon\": \"doc.on.clipboard\",\\n \"color\": \"#FF0000\",\\n \"name\": \"Paste\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n do() {\\n const text = $clipboard.text\\n if (!text || text === \"\") return\\n $keyboard.insert(text)\\n }\\n}\\n',readme:\"## Paste\\n\\n向输入框输入剪切板内的内容\"},PreviewMarkdown:{config:'{\\n \"icon\": \"book\",\\n \"color\": \"#9900CC\",\\n \"name\": \"预览Markdown\"\\n}',main:'class MyAction extends Action {\\n do() {\\n this.pageSheet({\\n view: {\\n type: \"markdown\",\\n props: { content: this.text },\\n layout: $layout.fill\\n }\\n })\\n }\\n}\\n',readme:\"## PreviewMarkdown\\n\\n预览Markdown。\"},Replace:{config:'{\\n \"icon\": \"square.and.arrow.up\",\\n \"color\": \"#FF3300\",\\n \"name\": \"查找替换\"\\n}',main:'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replaceAll(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replaceAll(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',readme:\"## Replace\\n\\n查找替换\"},SelectedText:{config:'{\\n \"icon\": \"crop\",\\n \"color\": \"#6699CC\",\\n \"name\": \"选中的文本\"\\n}',main:\"class MyAction extends Action {\\n do() {\\n if (this.selectedRange.length > 0) {\\n const selectedText = this.text\\n $ui.alert(selectedText)\\n }\\n }\\n}\\n\",readme:\"## SelectedText\\n\\n显示选中的文本。\"}},uncategorized:{ActionEditPreview:{config:'{\\r\\n \"icon\": \"play\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"编辑动作即时预览示例\"\\r\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n * @typedef {import(\"../../action\").ActionData} ActionData\\r\\n * @typedef {import(\"../../action\").ActionEnv} ActionEnv\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n preview() {\\r\\n return new ActionData({\\r\\n text: \"hello word\"\\r\\n })\\r\\n }\\r\\n\\r\\n async do() {\\r\\n try {\\r\\n if (this.env !== ActionEnv.build) {\\r\\n $ui.toast(\"action editor only\")\\r\\n return\\r\\n }\\r\\n return this.text\\r\\n } catch (error) {\\r\\n $ui.alert(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## ActionEditPreview\\r\\n\\r\\n编辑动作即时预览示例。\"},DeleteClips:{config:'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"删除所有剪切板\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\n\\nclass MyAction extends Action {\\n async do() {\\n try {\\n const action = await this.clearAllClips()\\n if (action) {\\n $ui.success($l10n(\"DONE\"))\\n }\\n } catch (error) {\\n $ui.error(error)\\n }\\n }\\n}\\n',readme:\"## DeleteClips\\n\\n删除所有已保存的剪切板(不包括收藏)。\"},DisplayClipboard:{config:'{\\n \"icon\": \"option\",\\n \"color\": \"#FF6633\",\\n \"name\": \"显示剪切板\"\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n const image = $clipboard.image\\r\\n if (image) {\\r\\n this.quickLookImage(image)\\r\\n } else {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"text\",\\r\\n props: {\\r\\n editable: false,\\r\\n text: $clipboard.text,\\r\\n insets: $insets(10, 10, 10, 10)\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## DisplayClipboard\\n\\n显示当前剪切板内的内容。\"},ExportAllContent:{config:'{\\n \"icon\": \"square.and.arrow.up\",\\n \"color\": \"#FF3300\",\\n \"name\": \"导出数据\"\\n}',main:'class MyAction extends Action {\\n do() {\\n const data = this.getAllClips()\\n if (data.clips.length > 0 || data.favorite.length > 0) {\\n $share.sheet(JSON.stringify(data, null, 2))\\n } else {\\n $ui.alert(\"无数据\")\\n }\\n }\\n}\\n',readme:\"## ExportAllContent\\n\\n导出所有保存的数据。\"}}},__ACTION_README__={content:'# Action\\r\\n\\r\\n所有 Action 保存在 `storage/user_action` 目录下,按照文件夹分类\\r\\n\\r\\n`Action` 结构如下:\\r\\n\\r\\n- `ActionName`\\r\\n - `config.json` 配置文件\\r\\n - `main.js` 入口文件\\r\\n - `README.md` 说明文件\\r\\n\\r\\n### `config.json` 配置项\\r\\n\\r\\n- `icon` 图标 可以是 [JSBox 内置图标](https://github.com/cyanzhong/xTeko/tree/master/extension-icons)、SF Symbols图标、base64图片数据和来自 url 的图片\\r\\n- `color` 颜色\\r\\n- `name` 名称\\r\\n- `description` 描述信息\\r\\n\\r\\n### `main.js` 入口文件\\r\\n\\r\\n创建名为 `MyAction` 的类并继承 `Action` 类\\r\\n\\r\\n```js\\r\\n/**\\r\\n * @typedef {import(\"scripts/action/action.js\").Action} Action\\r\\n */\\r\\n/**\\r\\n * 必须为 MyAction\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n * 在编辑模式如果提供了返回值,则可弹窗预览返回值\\r\\n */\\r\\n do() {\\r\\n console.log(this.text)\\r\\n }\\r\\n}\\r\\n```\\r\\n\\r\\n### 父类 `Action` 的属性:\\r\\n- `this.env` \\r\\n 当前运行环境,参见 [ActionEnv](#ActionEnv)\\r\\n- `this.config` \\r\\n 当前 Action 配置文件内容\\r\\n- `this.originalContent` \\r\\n 原始数据\\r\\n- `this.text` \\r\\n 优先为选中的文本,若无则:当处于键盘中运行时为输入框内文本,处于编辑器时为编辑器内文本,其他情况为剪切板内文本\\r\\n- `this.selectedRange` \\r\\n 在编辑器中,当前选中的文本范围 `{location: Number, length: Number}`\\r\\n\\r\\n更多参见 [ActionData](#ActionData)\\r\\n\\r\\n### 父类的方法:\\r\\n```js\\r\\n/**\\r\\n * 编辑动作状态下提供预览数据\\r\\n * @returns {ActionData}\\r\\n */\\r\\npreview(): ActionData\\r\\n\\r\\n/**\\r\\n * 重写该方法返回 l10n 对象可注入 l10n\\r\\n * l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n */\\r\\nl10n()\\r\\n\\r\\n/**\\r\\n * page sheet\\r\\n * @param {*} args \\r\\n * {\\r\\n view: args.view, // 视图对象\\r\\n title: args.title ?? \"\", // 中间标题\\r\\n done: args.done, // 点击左上角按钮后的回调函数\\r\\n doneText: args.doneText ?? $l10n(\"DONE\") // 左上角文本\\r\\n rightButtons: [{ title:string, symbol:string, tapped:function }] // 右上角按钮\\r\\n }\\r\\n */\\r\\npageSheet(args): void\\r\\n\\r\\n/**\\r\\n * 获取所有剪切板数据\\r\\n * @returns {object}\\r\\n */\\r\\ngetAllClips(): { favorite, clips }\\r\\n\\r\\n/**\\r\\n * 更新当前文本,当用户侧滑返回时才会触发保存操作\\r\\n */\\r\\nsetContent(text): void\\r\\n\\r\\n/**\\r\\n * 获取指定的 Action 类\\r\\n * @param {string} category\\r\\n * @param {string} name config.name\\r\\n * @param {ActionData} data new ActionData({ args: any })\\r\\n * @returns\\r\\n */\\r\\ngetAction(category, name, data): any\\r\\n\\r\\n/**\\r\\n * 运行指定的 Action 并返回该 Action do() 方法的返回值\\r\\n */\\r\\nasync runAction(category, name): any\\r\\n\\r\\n/**\\r\\n * 从 `this.text` 中匹配所有 url\\r\\n */\\r\\ngetUrls(): []\\r\\n\\r\\n/**\\r\\n * 运行其他 JSBox 脚本\\r\\n * @param {string} name\\r\\n */\\r\\naddinRun(name): void\\r\\n```\\r\\n\\r\\n### ActionEnv\\r\\n```js\\r\\nclass ActionEnv {\\r\\n static build = -1 // 动作编辑器\\r\\n static today = 0\\r\\n static editor = 1\\r\\n static clipboard = 2\\r\\n static action = 3\\r\\n static keyboard = 4\\r\\n}\\r\\n```\\r\\n\\r\\n### ActionData\\r\\n```js\\r\\nclass ActionData {\\r\\n env\\r\\n args // 其他动作传递的参数\\r\\n text // 自动获取文本,优先获取选中的文本\\r\\n allText // 获取所有文本\\r\\n section // 首页剪切板分类\\r\\n uuid // 首页剪切板项目 uuid\\r\\n selectedRange // 文本选中的范围\\r\\n selectedText // 选中的文本\\r\\n textBeforeInput // 键盘中输入光标之前的文本\\r\\n textAfterInput // 键盘中输入光标之后的文本\\r\\n editor // 编辑器\\r\\n}\\r\\n```\\r\\n\\r\\n其中 `editor` 如下:\\r\\n\\r\\n```js\\r\\nconst editor = {\\r\\n originalContent,\\r\\n setContent: text => {}\\r\\n}\\r\\n```\\r\\n'},$app.env){case $env.app:case $env.action:t=n(\"6olY1\");break;case $env.today:case $env.keyboard:case $env.siri:t=n(\"ljE8b\");break;case $env.widget:t=n(\"gD12U\");break;default:$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}t&&t.run()})();" + "value": "(()=>{let t;var e=globalThis,i={},s={},n=e.parcelRequire94c2;null==n&&((n=function(t){if(t in i)return i[t].exports;if(t in s){var e=s[t];delete s[t];var n={id:t,exports:{}};return i[t]=n,e.call(n.exports,n,n.exports),n.exports}var a=Error(\"Cannot find module '\"+t+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}).register=function(t,e){s[t]=e},e.parcelRequire94c2=n);var a=n.register;switch(a(\"6olY1\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.ViewController,r=i.TabBarController,o=n(\"8Makm\").AppKernelBase,l=n(\"gYDdO\"),h=n(\"iuWEe\");class c extends o{constructor(){super(),this.query=$context.query,h(this)}}class d{static kernel=new c;static renderMainUI(){let t={clips:{icon:\"doc.on.clipboard\",title:$l10n(\"CLIPS\")},actions:{icon:\"command\",title:$l10n(\"ACTIONS\")},setting:{icon:\"gear\",title:$l10n(\"SETTING\")}};if(s.isTaio||0===this.kernel.setting.get(\"mainUIDisplayMode\"))this.kernel.useJsboxNav(),this.kernel.setting.useJsboxNav(),this.kernel.setNavButtons([{symbol:t.setting.icon,title:t.setting.title,handler:()=>{s.push({title:t.setting.title,views:[this.kernel.setting.getListView()]})}},{symbol:t.actions.icon,title:t.actions.title,handler:()=>{this.kernel.actions.present()}}]),this.kernel.UIRender(this.kernel.clips.getNavigationView().getPage());else{this.kernel.fileManager.setViewController(new a),this.kernel.tabBarController=new r;let e=this.kernel.clips.getNavigationView();this.kernel.tabBarController.setPages({clips:e.getPage(),actions:this.kernel.actions.getPage(),setting:this.kernel.setting.getPage()}).setCells({clips:t.clips,actions:t.actions,setting:t.setting}),this.kernel.UIRender(this.kernel.tabBarController.generateView().definition)}}}t.exports={run:()=>{l(d.kernel),d.renderMainUI()}}}),a(\"gxpqj\",function(t,e){var i=class{title;handler;constructor({title:t=$l10n(\"OK\"),disabled:e=!1,style:i=$alertActionType.default,handler:s=()=>{}}={}){this.title=t,this.disabled=e,this.style=i,this.handler=s}},s=class t{id=$text.uuid;title;message;actions;titleFont=$font(\"bold\",20);messageFont=$font(14);actionButtonFontSize=16;actionButtonHighlight=$color($rgba(0,0,0,.2),$rgba(255,255,255,.2));actionButtonHeight=35;actionButtonBoderWidth=.5;actionButtonBorderColor=$color(\"#C9C9C9\",\"#383838\");boxWidth=250;textVerticalMargin=20;textHorizontalMargin=50;constructor({title:t=\"\",message:e=\"\",actions:s=[]}={}){this.title=t,this.message=e,this.actions=s,0===this.actions.length&&this.actions.push(new i),this.titleSize=m.getContentSize(this.titleFont,this.title,this.boxWidth-2*this.textHorizontalMargin),this.messageSize=m.getContentSize(this.messageFont,this.message,this.boxWidth-2*this.textHorizontalMargin)}textView(){return{type:\"view\",views:[{type:\"label\",props:{lines:0,font:this.titleFont,text:this.title,color:$color(\"tint\"),align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.titleSize.height),t.top.equalTo(this.textVerticalMargin)}},{type:\"label\",props:{lines:0,font:this.messageFont,text:this.message,align:$align.center},layout:(t,e)=>{t.centerX.equalTo(e.super),t.width.equalTo(this.boxWidth-2*this.textHorizontalMargin),t.height.equalTo(this.messageSize.height),t.top.equalTo(e.prev.bottom)}}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin)}}}actionView(){let t=(t,e)=>{let i=t=>2===this.actions.length?t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth/2:t.y>=0&&t.x>=0&&t.y<=this.actionButtonHeight&&t.x<=this.boxWidth,s=async(s,n,a)=>{t.disabled||(s.bgcolor=$color(\"clear\"),i(n)&&(\"function\"==typeof t.handler&&await t.handler({index:e,title:t.title}),this.dismiss()))},n=$color(\"tint\"),a=$font(this.actionButtonFontSize);return t.disabled?n=$color(\"gray\"):t.style===$alertActionType.destructive?n=$color(\"red\"):t.style===$alertActionType.cancel&&(a=$font(\"bold\",this.actionButtonFontSize)),{type:\"label\",props:{lines:1,text:t.title,align:$align.center,font:a,color:n,borderWidth:this.actionButtonBoderWidth,borderColor:this.actionButtonBorderColor,bgcolor:$color(\"clear\")},events:{tapped:()=>{},touchesBegan:e=>{t.disabled||(e.bgcolor=this.actionButtonHighlight)},touchesEnded:s,touchesCancelled:s,touchesMoved:(e,s,n)=>{t.disabled||(i(s)?e.bgcolor=this.actionButtonHighlight:e.bgcolor=$color(\"clear\"))}},layout:(t,e)=>{2===this.actions.length?e.prev?(t.left.equalTo(e.prev.right).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).dividedBy(2).offset(this.actionButtonBoderWidth)):t.width.equalTo(e.super).dividedBy(2):(t.width.equalTo(e.super),e.prev&&t.top.equalTo(e.prev.bottom).offset(-this.actionButtonBoderWidth)),t.height.equalTo(this.actionButtonHeight)}}};return{type:\"view\",views:this.actions.map((e,i)=>t(e,i)),layout:(t,e)=>{t.left.equalTo(e.super).offset(-this.actionButtonBoderWidth),t.width.equalTo(e.super).offset(2*this.actionButtonBoderWidth),t.bottom.equalTo(e.super),t.top.equalTo(e.prev.bottom)}}}getView(){let t={type:\"view\",props:{id:this.id+\"-box\",smoothCorners:!0,cornerRadius:20,bgcolor:$color(\"#FFFFFF\",\"#000000\")},views:[this.textView(),this.actionView()],layout:(t,e)=>{t.center.equalTo(e.super.safeArea);let i=this.titleSize.height+this.messageSize.height+2*this.textVerticalMargin,s=this.actions.length>2?this.actions.length:1;i+=this.actionButtonHeight*s,i-=this.actionButtonBoderWidth*s;let n=this.boxWidth-2*this.actionButtonBoderWidth;t.size.equalTo($size(n,i))}};return{type:\"view\",props:{id:this.id,alpha:0,bgcolor:$rgba(0,0,0,.6)},views:[t],layout:$layout.fill}}present(){let t=$ui.create(this.getView());$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout($layout.fill),e.moveToFront(),$ui.animate({duration:.3,animation:()=>{e.alpha=1}})}dismiss(){let t=$(this.id);$ui.animate({duration:.3,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static fromJsbox(e){return new Promise((s,n)=>{new t({title:e.title,message:e.message,actions:e?.actions?.map(t=>(t.handler||(t.handler=t=>{s(t)}),new i(t)))}).present()})}},n=class{events={};setEvents(t){return Object.keys(t).forEach(e=>this.setEvent(e,t[e])),this}setEvent(t,e){return this.events[t]=e,this}appendEvent(t,e){let i=this.events[t];return\"function\"==typeof i?this.events[t]=(...t)=>{i(...t),e(...t)}:this.setEvent(t,e),this}callEvent(t,...e){\"function\"==typeof this.events[t]&&this.events[t](...e)}},a=class{viewController;constructor(){this.edges=10,this.iconSize=25}setViewController(t){this.viewController=t}get menu(){return{items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:async(t,e)=>{let i=t.object(e).info.info;$share.sheet([$file.absolutePath(i.path)])}}]}}delete(t){$file.delete(t.path)}edit(t){let e=$file.read(t.path);if(e.info?.mimeType?.startsWith(\"image\"))g.quickLookImage(e,t.path.substring(t.path.lastIndexOf(\"/\")+1));else{let i=new g,s=$text.uuid;i.setView({type:\"code\",layout:$layout.fill,props:{id:s,lineNumbers:!0,theme:$device.isDarkMode?\"atom-one-dark\":\"atom-one-light\",text:e.string,insets:$insets(15,15,15,15)}}).addNavBar({title:t.file,popButton:{title:$l10n(\"CLOSE\")},rightButtons:[{title:$l10n(\"SAVE\"),tapped:()=>{$file.write({data:$data({string:$(s).text}),path:t.path}),$ui.success($l10n(\"SAVE_SUCCESS\"))}}]}),i.init().present()}}getFiles(t=\"\"){return $file.list(t).map(e=>{let i=t+\"/\"+e,s=$file.isDirectory(i);return{info:{info:{path:i,file:e,isDirectory:s}},icon:{symbol:s?\"folder.fill\":\"doc\"},name:{text:e},size:{text:s?\"\":\"--\"}}}).sort((t,e)=>t.info.info.isDirectory!==e.info.info.isDirectory?t.info.info.isDirectory?-1:1:t.info.info.isDirectory===e.info.info.isDirectory?t.info.info.file.localeCompare(e.info.info.file):void 0)}async loadFileSize(t){return t.map((e,i)=>{let s=e.info.info;if(!s.isDirectory)try{t[i].size.text=m.bytesToSize($file.read(s.path).info.size)}catch(e){t[i].size.text=e}}),t}get listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{props:{id:\"info\"}},{type:\"image\",props:{id:\"icon\"},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(this.edges),t.size.equalTo(this.iconSize)}},{type:\"view\",views:[{type:\"label\",props:{id:\"size\",color:$color(\"secondaryText\"),lines:1},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(this.edges)}},{type:\"label\",props:{id:\"name\",lines:1},layout:(t,e)=>{t.height.left.equalTo(e.super),t.right.equalTo(e.prev.left).offset(-this.edges)}}],layout:(t,e)=>{t.height.right.equalTo(e.super),t.left.equalTo(e.prev.right).offset(this.edges)}}]}}#t(t){let e=t.lastIndexOf(\"/\"),i=t.substring(e<0?0:e+1),s=this.getListView(t),n=async()=>{let e=$file.absolutePath(t);0===(await $ui.alert({title:\"Path\",message:e,actions:[{title:$l10n(\"COPY\")},{title:$l10n(\"OK\")}]})).index&&($clipboard.text=e,$ui.toast($l10n(\"COPIED\")))};if(this.viewController){let t=new N;t.setView(s).navigationBarTitle(i),t.navigationBar.setLargeTitleDisplayMode(O.largeTitleDisplayModeNever),t.navigationBarItems.addRightButton({symbol:\"info.circle\",tapped:n}),this.viewController.push(t)}else m.push({title:i,views:[s],navButtons:[{symbol:\"info.circle\",handler:n}]})}getListView(t=\"\"){return{type:\"list\",props:{menu:this.menu,bgcolor:m.primaryViewBackgroundColor,separatorInset:$insets(0,this.edges,0,0),data:[],template:this.listTemplate,actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:(t,e)=>{let i=t.object(e).info.info;m.deleteConfirm($l10n(\"FILE_MANAGER_DELETE_CONFIRM_MSG\")+' \"'+i.file+'\" ?',()=>{this.delete(i),t.delete(e)})}}]},layout:$layout.fill,events:{ready:e=>{let i=this.getFiles(t);e.data=i,this.loadFileSize(i).then(t=>{e.data=t})},pulled:async e=>{let i=this.getFiles(t);e.data=i,e.data=await this.loadFileSize(i),$delay(.5,()=>{e.endRefreshing()})},didSelect:(t,e,i)=>{let s=i.info.info;s.isDirectory?this.#t(s.path):this.edit(s)}}}}push(t=\"\"){this.#t(t)}},r=class t{basePath;constructor({basePath:t=\"storage\"}={}){this.basePath=t,this.#t(this.basePath)}static join(...t){let e=t.length,i=t[0];if(e<2)return i;for(let s=0;st&&(s=e.substring(t+1),e=e.substring(0,t+1))}return i&&this.#t(e),e+s}exists(t=\"\"){return t=this.filePath(t,!1),!!$file.exists(t)}write(t=\"\",e){return new Promise((i,s)=>{try{let n=this.writeSync(t,e);n?i(n):s(n)}catch(t){s(t)}})}writeSync(t=\"\",e){if(!e)throw new v(\"data\");return $file.write({data:e,path:this.filePath(t)})}read(t=\"\"){return new Promise((e,i)=>{try{let s=this.readSync(t);s?e(s):i()}catch(t){i(t)}})}readSync(t=\"\"){if(t=this.filePath(t),!$file.exists(t))throw new T(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}readAsJSON(t=\"\",e=null){try{let e=this.readSync(t)?.string;return JSON.parse(e)}catch{return e}}static readFromRoot(e=\"\"){return new Promise((i,s)=>{try{let n=t.readFromRootSync(e);n?i(n):s()}catch(t){s(t)}})}static readFromRootSync(t=\"\"){if(!t)throw new v(\"path\");if(!$file.exists(t))throw new T(t);return $file.isDirectory(t)?$file.list(t):$file.read(t)}static readFromRootAsJSON(e=\"\",i=null){try{let i=t.readFromRootSync(e)?.string;return JSON.parse(i)}catch{return i}}delete(t=\"\"){return $file.delete(this.filePath(t,!1))}copy(t,e){t=this.filePath(t),e=this.filePath(e),$file.copy({src:t,dst:e})}move(t,e){t=this.filePath(t),e=this.filePath(e),$file.move({src:t,dst:e})}},o=class t{startTime=Date.now();isUseJsboxNav=!1;title=$addin?.current?.name;constructor(){$app.isDebugging&&(console.log(\"You are running EasyJsBox in debug mode.\"),$app.idleTimerDisabled=!0),l.init()}static isObject(t){return null!=t&&\"object\"==typeof t}static objectEqual(e,i){let s=Object.keys(e),n=Object.keys(i);if(s.length!==n.length)return!1;s.sort(),n.sort();for(let t=0;tt?i[t]:0,n=isNaN(Number(e))?e.charCodeAt():Number(e),r=s.length>t?s[t]:0,o=isNaN(Number(r))?r.charCodeAt():Number(r);if(no){a=1;break}}return a}useJsboxNav(){return this.isUseJsboxNav=!0,this}setTitle(t){this.isUseJsboxNav&&($ui.title=t),this.title=t}setNavButtons(t){this.navButtons=t}openInJsbox(){$app.openURL(`jsbox://run?name=${this.title}`)}UIRender(t={}){let e=$context.query;if(\"alertFromKeyboard\"===e.type){let t=JSON.parse($text.URLDecode(e.value));t.actions=[{title:$l10n(\"CANCEL\")}],$ui.alert(t);return}try{t.props=Object.assign({title:this.title,navBarHidden:!this.isUseJsboxNav,navButtons:this.navButtons??[],statusBarStyle:0},t.props),t.events||(t.events={});let e=t.events.layoutSubviews;t.events.layoutSubviews=()=>{$app.notify({name:\"interfaceOrientationEvent\",object:{statusBarOrientation:m.statusBarOrientation,isHorizontal:m.isHorizontal}}),\"function\"==typeof e&&e()},$ui.render(t)}catch(t){this.print(t)}}KeyboardRender(t={}){t.id||(t.id=$text.uuid),$ui.render(),$delay(0,()=>{$ui.controller.view=$ui.create(t),$ui.controller.view.layout(t.layout)})}KeyboardRenderWithViewFunc(t){$ui.render(),$delay(0,()=>{$ui.controller.view=$ui.create({type:\"view\"}),$delay(0,async()=>{let e=await t();e.id||(e.id=$text.uuid),$ui.controller.view=$ui.create(e),$ui.controller.view.layout(e.layout)})})}async checkUpdate(){let e=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/src/version.js\");if(e.error)throw e.error;let i=e.data.match(/.*VERSION.+\\\"([0-9\\.]+)\\\"/)[1];if(this.print(`easy-jsbox latest version: ${i}`),t.versionCompare(i,\"1.4.5\")>0){let t=await $http.get(\"https://raw.githubusercontent.com/ipuppet/EasyJsBox/dev/dist/easy-jsbox.js\");if(t.error)throw t.error;return t.data}return!1}},l=class{static l10n(t,e,i){if(\"string\"==typeof e){let t={};e.split(\";\").forEach(e=>{if(\"\"!==(e=e.trim())){let i=e.split(\"=\");t[i[0].trim().slice(1,-1)]=i[1].trim().slice(1,-1)}}),e=t}let s=$app.strings;if(i)Object.assign(s[t],e);else for(let i in e)s[t][i]||(s[t][i]=e[i]);$app.strings=s}static set(t,e){this.l10n(t,e,!0)}static add(t,e){this.l10n(t,e,!1)}static init(){this.add(\"zh-Hans\",{OK:\"好\",DONE:\"完成\",CANCEL:\"取消\",CLEAR:\"清除\",BACK:\"返回\",ERROR:\"发生错误\",SUCCESS:\"成功\",INVALID_VALUE:\"非法参数\",CONFIRM_CHANGES:\"数据已变化,确认修改?\",SETTING:\"设置\",GENERAL:\"一般\",ADVANCED:\"高级\",TIPS:\"小贴士\",COLOR:\"颜色\",COPY:\"复制\",COPIED:\"复制成功\",JSBOX_ICON:\"JSBox 内置图标\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"图片 / base64\",PREVIEW:\"预览\",SELECT_IMAGE_PHOTO:\"从相册选择图片\",SELECT_IMAGE_ICLOUD:\"从 iCloud 选择图片\",CLEAR_IMAGE:\"清除图片\",NO_IMAGE:\"无图片\",ABOUT:\"关于\",VERSION:\"Version\",AUTHOR:\"作者\",AT_BOTTOM:\"已经到底啦~\"}),this.add(\"en\",{OK:\"OK\",DONE:\"Done\",CANCEL:\"Cancel\",CLEAR:\"Clear\",BACK:\"Back\",ERROR:\"Error\",SUCCESS:\"Success\",INVALID_VALUE:\"Invalid value\",CONFIRM_CHANGES:\"The data has changed, confirm the modification?\",SETTING:\"Setting\",GENERAL:\"General\",ADVANCED:\"Advanced\",TIPS:\"Tips\",COLOR:\"Color\",COPY:\"Copy\",COPIED:\"Copide\",JSBOX_ICON:\"JSBox in app icon\",SF_SYMBOLS:\"SF Symbols\",IMAGE_BASE64:\"Image / base64\",PREVIEW:\"Preview\",SELECT_IMAGE_PHOTO:\"Select From Photo\",SELECT_IMAGE_ICLOUD:\"Select From iCloud\",CLEAR_IMAGE:\"Clear Image\",NO_IMAGE:\"No Image\",ABOUT:\"About\",VERSION:\"Version\",AUTHOR:\"Author\",AT_BOTTOM:\"It's the end~\"}),this.add(\"zh-Hans\",{DELETE_CONFIRM_TITLE:\"删除前确认\"}),this.add(\"en\",{DELETE_CONFIRM_TITLE:\"Delete Confirmation\"}),this.add(\"zh-Hans\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"确认要删除吗\",DELETE:\"删除\",CANCEL:\"取消\",CLOSE:\"关闭\",SHARE:\"分享\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\"}),this.add(\"en\",{FILE_MANAGER_DELETE_CONFIRM_MSG:\"Are you sure you want to delete\",DELETE:\"Delete\",CANCEL:\"Cancel\",CLOSE:\"Close\",SHARE:\"Share\",SAVE:\"Save\",SAVE_SUCCESS:\"Save Success\"})}},h=class t{static level={info:\"info\",warn:\"warn\",error:\"error\"};writer;fsLevels=[t.level.error];printToFile(t){this.fsLevels=t}setWriter(t,e){this.writer=i=>{t.exists(e)&&(i=(t.readSync(e)?.string??\"\")+i),t.writeSync(e,$data({string:i}))}}format(t,e){return`${new Date().toUTCString()} [${e.toUpperCase()}] ${t}\n`}log(t,e){this.writer&&this.fsLevels.includes(e)&&this.writer(this.format(t,e)),$app.isDebugging&&console[e](t)}info(e){this.log(e,t.level.info)}warn(e){this.log(e,t.level.warn)}error(e){this.log(e,t.level.error)}},c=class{rightButtons=[];leftButtons=[];#t={};hasbutton=!1;isPinTitleView=!1;setTitleView(t){return this.titleView=t,this}pinTitleView(){return this.isPinTitleView=!0,this}setFixedFooterView(t){return this.fixedFooterView=t,this}setRightButtons(t){return t.forEach(t=>this.addRightButton(t)),this.hasbutton||(this.hasbutton=!0),this}setLeftButtons(t){return t.forEach(t=>this.addLeftButton(t)),this.hasbutton||(this.hasbutton=!0),this}addRightButton({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r}={}){let o=B.creat({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r,align:m.align.right});return this.rightButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}addLeftButton({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r}={}){let o=B.creat({id:t,symbol:e,title:i,tapped:s,menu:n,events:a,color:r,align:m.align.left});return this.leftButtons.push(o),this.#t[t??o.id]=o,this.hasbutton||(this.hasbutton=!0),this}getButton(t){return this.#t[t]}getButtons(){return Object.values(this.#t)}addPopButton(t,e,i){return t||(t=$l10n(\"BACK\")),this.popButtonView=e??{type:\"button\",props:{bgcolor:$color(\"clear\"),symbol:\"chevron.left\",tintColor:m.linkColor,title:` ${t}`,titleColor:m.linkColor,font:$font(\"bold\",16)},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(B.style.edges),t.centerY.equalTo(e.super.safeArea)},events:{tapped:()=>{$ui.pop(),\"function\"==typeof i&&i()}}},this}removePopButton(){return this.popButtonView=void 0,this}},d=class{constructor(t){this.content=t}valueToJs(t){switch(t.tag){case\"dict\":return this.dictToJs(t);case\"true\":case\"false\":return\"true\"===t.tag;case\"integer\":return t.number;case\"key\":case\"string\":return t.string;case\"date\":return new Date(t.string);case\"array\":return this.arrayToJs(t);default:return t.node}}arrayToJs(t){let e=[];return t.children().forEach(t=>{e.push(this.valueToJs(t))}),e}dictToJs(t){let e=[],i=[];return t.children().forEach(t=>{\"key\"===t.tag?e.push(this.valueToJs(t)):i.push(this.valueToJs(t))}),Object.fromEntries(e.map((t,e)=>[t,i[e]]))}getObject(){if(!this.content)return!1;let t=$xml.parse({string:this.content,mode:\"xml\"});return this.valueToJs(t.rootElement.firstChild({xPath:\"//plist/dict\"}))}static get(t){return new this(t).getObject()}},u=class t{static method={get:\"GET\",post:\"POST\",put:\"PUT\",delete:\"DELETE\",patch:\"PATCH\",head:\"HEAD\",options:\"OPTIONS\"};static errorType={http:0,network:1};cacheContainerKey=$addin?.current?.name+\".request.cache\";#t;#e=!1;#i=!1;cacheLife=2592e6;#s=!1;timeout=5;logger;constructor(t){t instanceof h&&(this.logger=t)}get cache(){return $cache.get(this.cacheContainerKey)??{}}#n(t){this.#s&&this.logger instanceof h&&this.logger.info(t)}logRequest(){return this.#s=!0,this}disableLogRequest(){this.#s=!1}getCacheKey(t){return $text.MD5(t)}getCache(t,e=null){return this.cache[t]??e}setCache(t,e){if(!e)return;let i=this.cache;i[t]=e,$cache.set(this.cacheContainerKey,i)}removeCache(t){let e=this.cache;delete e[t],$cache.set(this.cacheContainerKey,e)}clearCache(){$cache.remove(this.cacheContainerKey)}clearNSURLCache(){this.#t||(this.#t=$objc(\"NSURLCache\").$sharedURLCache()),this.#t.$removeAllCachedResponses()}enableCache(){return this.#e=!0,this}disableCache(){return this.#e=!1,this}ignoreCacheExp(){this.#i=!0}async request(e,i,s={},n={},a=this.cacheLife,r){let o,l=this.#e&&i===t.method.get;if(l){o=this.getCacheKey(e);let t=this.getCache(o);if(t&&(this.#i||t.exp>Date.now()))return this.#n(\"get data from cache: \"+e),t.data}this.#n(`sending request [${i}]: ${e}`);let h=await $http.request(Object.assign({header:n,url:e,method:i,body:i===t.method.get?null:s,timeout:this.timeout},r));if(h.error)throw new A({type:t.errorType.network,message:h.error.localizedDescription,code:h.error.code});if(h?.response?.statusCode>=400){let e=h.data;throw\"object\"==typeof e&&(e=JSON.stringify(e)),new A({type:t.errorType.http,message:e,code:h.response.statusCode})}return l&&this.setCache(o,{exp:Date.now()+a,data:h}),h}},p=class t{static rowHeight=50;static edgeOffset=10;static iconSize=30;static iconDefaultColor=\"#00CC00\";setting;#t;#e;#i;title;#s={};#n;constructor({setting:t,key:e,title:i,icon:s,value:n=null}={}){this.setting=t,this.key=e,this.title=$l10n(i),this.icon=s,this.default=n}get method(){return this.setting.method}set key(t){return this.#e=t??$text.uuid,this.#t=void 0,this}get key(){return this.#e}get id(){return this.#t||(this.#t=`setting-${$text.uuid}-${this.key}`),this.#t}set icon(e){return e?Array.isArray(e)||(e=[e,t.iconDefaultColor]):e=[\"square.grid.2x2.fill\",t.iconDefaultColor],Array.isArray(e[0])||(e[0]=[e[0],e[0]]),e[1]?Array.isArray(e[1])||(e[1]=[e[1],e[1]]):e[1]=[t.iconDefaultColor,t.iconDefaultColor],this.#i=e,this}get icon(){return this.#i}get options(){return this.#s}set options(t){return this.#s=t??{},this}set(t){return\"function\"==typeof this.#n&&this.#n(t),this.setting.set(this.key,t)}onSet(t){return this.#n=t,this}get(t=this.default){return this.setting.getOriginal(this.key,t)}evalValues(t,e=[]){return\"string\"==typeof t?t.startsWith(\"this.method\")?Function(\"method\",`return ${t.replace(\"this.\",\"\")}()`)(this.method):Function(`return {${t}}`)():\"function\"==typeof t?t():t??e}createLineLabel(){return{type:\"view\",views:[{type:\"view\",props:{bgcolor:$color(this.icon[1][0],this.icon[1][1]),cornerRadius:5,smoothCorners:!0},views:[{type:\"image\",props:Object.assign({tintColor:$color(\"white\")},this.icon[0][0].startsWith(\"icon_\")?{icon:$icon(this.icon[0][0].slice(5,this.icon[0][0].indexOf(\".\")>0?this.icon[0][0].indexOf(\".\"):this.icon[0][0].length),$color(\"#ffffff\"))}:{image:$image(this.icon[0][0],this.icon[0][1])}),layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(20)}}],layout:(e,i)=>{e.centerY.equalTo(i.super),e.size.equalTo(t.iconSize),e.left.inset(t.edgeOffset)}},{type:\"label\",props:{text:this.title,lines:1,align:$align.left},layout:(e,i)=>{e.centerY.equalTo(i.super),e.height.equalTo(i.super),e.left.equalTo(i.prev.right).offset(t.edgeOffset),e.width.greaterThanOrEqualTo(10)}}],layout:(t,e)=>{t.height.centerY.equalTo(e.super),t.left.inset(0)}}}getView(){}create(){return this.getView(this.options)}},g=class t{#t=()=>{};#e=()=>{};style=t.UIModalPresentationStyle.PageSheet;#i=!1;#s;#n;#a;static UIModalPresentationStyle={Automatic:-2,FullScreen:0,PageSheet:1,FormSheet:2,CurrentContext:3,Custom:4,OverFullScreen:5,OverCurrentContext:6,Popover:7,BlurOverFullScreen:8};navigationView;init(){this.initNavBar(),$define({type:\"SheetViewController: UIViewController\",events:{\"viewWillDisappear:\":t=>{\"function\"==typeof this.#n&&this.#n(t)},\"viewDidDisappear:\":t=>{\"function\"==typeof this.#a&&this.#a(t)}}}),this.sheetVC=$objc(\"SheetViewController\").$new();let t=this.sheetVC.$view();return t.$addSubview($ui.create({type:\"view\"})),this.sheetVC.$setModalPresentationStyle(this.style),this.sheetVC.$setModalInPresentation(this.#i),this.#t=()=>{t.jsValue().add(this.navigationView?.getPage().definition??this.view),$ui.vc.ocValue().invoke(\"presentViewController:animated:completion:\",this.sheetVC,!0,null)},this.#e=()=>this.sheetVC.invoke(\"dismissViewControllerAnimated:completion:\",!0,null),this}initNavBar(){if(!this.#s)return;let{title:e=\"\",popButton:i={title:$l10n(\"CLOSE\")},rightButtons:s=[]}=this.#s;if(void 0===this.view)throw new I;this.navigationView=new N;let n=this.navigationView.navigationBar;n.setLargeTitleDisplayMode(O.largeTitleDisplayModeNever),n.navigationBarLargeTitleHeight-=n.navigationBarNormalHeight,n.navigationBarNormalHeight=m.PageSheetNavigationBarNormalHeight,n.navigationBarLargeTitleHeight+=n.navigationBarNormalHeight,this.style===t.UIModalPresentationStyle.FullScreen||this.style===t.UIModalPresentationStyle.OverFullScreen||this.style===t.UIModalPresentationStyle.BlurOverFullScreen?n.setTopSafeArea():n.removeTopSafeArea(),i.events=Object.assign({tapped:async()=>{\"function\"==typeof i.tapped&&await i.tapped(),this.dismiss()}},i.events??{}),this.navigationView.navigationBarItems.addLeftButton(i).setRightButtons(s),this.navigationView.setView(this.view).navigationBarTitle(e),this.view.props?.bgcolor&&this.navigationView?.getPage().setProp(\"bgcolor\",this.view.props?.bgcolor)}preventDismiss(){return this.#i=!0,this}setStyle(t){return this.style=t,this}setView(t={}){if(\"object\"!=typeof t)throw new te(\"view\",\"object\");return this.view=t,this}addNavBar(t){return this.#s=t,this}present(){this.#t()}dismiss(){this.#e()}willDismiss(t){return this.#n=t,this}didDismiss(t){return this.#a=t,this}static quickLookImage(e,i=$l10n(\"PREVIEW\")){new t().setView({type:\"view\",views:[{type:\"scroll\",props:{zoomEnabled:!0,maxZoomScale:3},layout:$layout.fill,views:[{type:\"image\",props:{data:e},layout:$layout.fill}]}],layout:$layout.fill}).addNavBar({title:i,rightButtons:[{symbol:\"square.and.arrow.up\",tapped:()=>$share.sheet(e)}]}).init().present()}},y=class{#t={};addTask(t,e=0){let i=$text.uuid;return this.#t[i]=$delay(e,async()=>{await t(),delete this.#t[i]}),i}cancelTask(t){this.#t[t].cancel()}clearTasks(){Object.values(this.#t).forEach(t=>t.cancel())}},f=class t{static type={info:void 0,success:\"checkmark\",warning:\"exclamationmark.triangle\",error:\"xmark.circle\"};static edges=40;static iconSize=100;static labelTopMargin=10;static defaultFont=$font(\"default\",26);width=Math.min(.6*m.windowSize.width,260);labelWidth=this.width-2*t.edges;id=$text.uuid;#t=\"\";font=t.defaultFont;type=t.type.info;labelLines=2;constructor(e,i=t.type.info,s=2,n=t.defaultFont){this.type=i,this.message=e,this.labelLines=s,this.font=n}get message(){return this.#t}set message(e){this.#t=e,this.fontHeight=m.getContentSize(this.font,this.message,this.labelWidth,this.labelLines).height,this.height=(this.hasIcon?t.labelTopMargin+t.iconSize:0)+this.fontHeight+2*t.edges}get hasIcon(){return void 0!==this.type}get blurBox(){let e=m.blurBox({id:this.id,cornerRadius:15,alpha:0},[{type:\"image\",props:{symbol:this.type,hidden:!this.hasIcon,tintColor:$color(\"lightGray\")},layout:(e,i)=>{e.top.inset(t.edges),e.size.equalTo(t.iconSize),e.centerX.equalTo(i.super)}},{type:\"label\",props:{font:this.font,text:this.message,align:$align.center,lines:this.labelLines,color:$color(\"lightGray\")},layout:(e,i)=>{e.bottom.equalTo(i.supper).offset(-t.edges),e.width.equalTo(this.labelWidth),e.height.equalTo(this.fontHeight),e.centerX.equalTo(i.super)}}]);return e.events={tapped:()=>{this.remove()}},e}show(){let t=$ui.create(this.blurBox);$ui.controller.view.hidden?$ui.controller.view.super.insertAtIndex(t,0):$ui.controller.view.insertAtIndex(t,0);let e=$(this.id);e.layout((t,e)=>{t.center.equalTo(e.super),t.size.equalTo($size(this.width,this.height))}),e.moveToFront(),$ui.animate({duration:.2,animation:()=>{e.alpha=1}})}remove(){let t=$(this.id);t&&$ui.animate({duration:.2,animation:()=>{t.alpha=0},completion:()=>{t.remove()}})}static toast({message:e,type:i=t.type.info,show:s=!0,displayTime:n=2,labelLines:a=2,font:r=t.defaultFont}){let o=new t(e,i,a,r);return s&&(o.show(),$delay(n,()=>{o.remove()})),o}static info(e,i={}){return t.toast(Object.assign({message:e,type:t.type.info},i))}static success(e,i={}){return t.toast(Object.assign({message:e,type:t.type.success},i))}static warning(e,i={}){return t.toast(Object.assign({message:e,type:t.type.warning},i))}static error(e,i={}){return t.toast(Object.assign({message:e,type:t.type.error},i))}},m=class t{static #t=$objc(\"UIApplication\").$sharedApplication();static #e=$objc(\"UINotificationFeedbackGenerator\").$new();static feedbackSuccess(){t.#e.$notificationOccurred(0)}static feedbackError(){t.#e.$notificationOccurred(2)}static isTaio=$app.info.bundleID.includes(\"taio\");static align={left:0,right:1,top:2,bottom:3};static textColor=$color(\"primaryText\");static linkColor=$color(\"systemLink\");static primaryViewBackgroundColor=$color(\"primarySurface\");static scrollViewBackgroundColor=$color(\"insetGroupedBackground\");static scrollViewList=[\"list\",\"matrix\"];static isLargeScreen=$device.isIpad||$device.isIpadPro;static get windowSize(){return $objc(\"UIWindow\").$keyWindow().jsValue().size}static NavigationBarNormalHeight=$objc(\"UINavigationController\").invoke(\"alloc.init\").$navigationBar().jsValue().frame.height;static NavigationBarLargeTitleHeight=$objc(\"UITabBarController\").invoke(\"alloc.init\").$tabBar().jsValue().frame.height+t.NavigationBarNormalHeight;static PageSheetNavigationBarNormalHeight=56;static get isSplitScreenMode(){return t.isLargeScreen&&$device.info.screen.width!==t.windowSize.width}static get topSafeAreaInsets(){return t.isTaio?0:t.#t?.$keyWindow()?.$safeAreaInsets()?.top??0}static get bottomSafeAreaInsets(){return t.#t?.$keyWindow()?.$safeAreaInsets()?.bottom??0}static get statusBarOrientation(){return t.#t.$statusBarOrientation()}static get consoleBarHeight(){if($app.isDebugging){let e=t.#t.$statusBarFrame().height+26;return $device.isIphoneX&&(e+=30),e}return 0}static get isHorizontal(){return 3===t.statusBarOrientation||4===t.statusBarOrientation}static loading(){let e=$ui.create(t.blurBox({cornerRadius:15},[{type:\"spinner\",props:{loading:!0,style:0},layout:(t,e)=>{t.size.equalTo(e.prev),t.center.equalTo(e.super)}}]));return{start:()=>{$ui.controller.view.insertAtIndex(e,0),e.layout((e,i)=>{e.center.equalTo(i.super);let s=Math.min(.6*Math.min(t.windowSize.width,t.windowSize.height),260);e.size.equalTo($size(s,s))}),e.moveToFront()},end:()=>{e.remove()}}}static defaultBackgroundColor(e){return t.scrollViewList.indexOf(e)>-1?t.scrollViewBackgroundColor:t.primaryViewBackgroundColor}static separatorLine(e={},i=t.align.bottom){return{type:\"canvas\",props:e,layout:(e,s)=>{void 0===s.prev?e.top.equalTo(s.super):i===t.align.bottom?e.top.equalTo(s.prev.bottom):e.top.equalTo(s.prev.top),e.height.equalTo(1/$device.info.screen.scale),e.left.right.inset(0)},events:{draw:(t,i)=>{i.strokeColor=e.bgcolor??$color(\"separatorColor\"),i.setLineWidth(1),i.moveToPoint(0,0),i.addLineToPoint(t.frame.width,0),i.strokePath()}}}}static blurBox(t={},e=[],i=$layout.fill){return{type:\"blur\",props:Object.assign({style:$blurStyle.thinMaterial},t),views:e,layout:i}}static getContentSize(e,i=\"A\",s=t.windowSize.width,n){let a={text:i,width:s,font:e};return void 0!==n&&(a.lineSpacing=n),$text.sizeThatFits(a)}static getSymbolSize(t,e){let i=(t=\"string\"==typeof t?$image(t):t).size.width/t.size.height;return t.size.width>t.size.height?$size(e,e/i):$size(e*i,e)}static push({views:t,statusBarStyle:e=0,title:i=\"\",navButtons:s=[{title:\"\"}],bgcolor:n=t[0]?.props?.bgcolor??\"primarySurface\",titleView:a,disappeared:r}={}){let o={statusBarStyle:e,navButtons:s,title:i,bgcolor:\"string\"==typeof n?$color(n):n};a&&(o.titleView=a),$ui.push({props:o,events:{disappeared:()=>{void 0!==r&&r()}},views:[{type:\"view\",views:t,layout:(t,e)=>{t.top.equalTo(e.super.safeArea),t.bottom.equalTo(e.super),t.left.right.equalTo(e.super.safeArea)}}]})}static compressImage(t,e=921600){let i=$imagekit.info(t);if(i.height*i.width>e){let s=e/(i.height*i.width);t=$imagekit.scaleBy(t,s)}return t}static deleteConfirm(t,e){$ui.alert({title:$l10n(\"DELETE_CONFIRM_TITLE\"),message:t,actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{e()}},{title:$l10n(\"CANCEL\")}]})}static bytesToSize(t){if(0===t)return\"0 B\";let e=Math.floor(Math.log(t)/Math.log(1024));return(t/Math.pow(1024,e)).toPrecision(3)+\" \"+[\"B\",\"KB\",\"MB\",\"GB\",\"TB\",\"PB\",\"EB\",\"ZB\",\"YB\"][e]}},w=class{#t;text=\"\";interval;fullScreen=!1;#e=()=>{};constructor(){this.#t=$text.uuid}updateText(t){$(this.#t).text=t}setLoop(t){if(\"function\"!=typeof t)throw\"loop must be a function\";this.#e=t}done(){clearInterval(this.interval)}load(){$ui.render({props:{navBarHidden:this.fullScreen},views:[{type:\"spinner\",props:{loading:!0},layout:(t,e)=>{t.centerY.equalTo(e.super).offset(-15),t.width.equalTo(e.super)}},{type:\"label\",props:{id:this.#t,align:$align.center,text:\"\"},layout:(t,e)=>{t.top.equalTo(e.prev.bottom).offset(10),t.left.right.equalTo(e.super)}}],layout:$layout.fill,events:{appeared:()=>{this.interval=setInterval(()=>{this.#e()},100)}}})}},b=class t{id=$text.uuid;type;props;views;events;layout;#t=void 0;#e=null;constructor({type:t=\"view\",props:e={},views:i=[],events:s={},layout:n=$layout.fill}={}){this.type=t,this.props=e,this.views=i,this.events=s,this.layout=n,this.props.id?this.id=this.props.id:this.props.id=this.id}static create(t){return new this(t)}static createFromViews(t){return new this({views:t})}get scrollableView(){return this.scrollable?this.#e:null}set scrollableView(t){this.#e=t}get scrollable(){if(void 0===this.#t){if(this.#t=!1,m.scrollViewList.indexOf(this.type)>-1)this.scrollableView=this,this.#t=!0;else if(this.views.length>0){let e=i=>{if(!this.#t&&i?.length>0)for(let s=0;s-1){typeof i[s]!==t&&(i[s]=t.create(i[s])),this.scrollableView=i[s],this.#t=!0;return}else e(i[s].views)};e(this.views)}}return this.#t}set scrollable(t){throw Error(\"[scrollable] is readonly prop.\")}setProps(t){return Object.keys(t).forEach(e=>this.setProp(e,t[e])),this}setProp(t,e){return\"id\"===t&&(this.id=e),this.props[t]=e,this}setViews(t){return this.views=t,this.#t=void 0,this}setEvents(t){return Object.keys(t).forEach(e=>this.setEvent(e,t[e])),this}setEvent(t,e){return this.events[t]=e,this}eventMiddleware(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&e(i,...t)},this}assignEvent(t,e){let i=this.events[t];return this.events[t]=(...t)=>{\"function\"==typeof i&&i(...t),e(...t)},this}setLayout(t){return this.layout=t,this}getView(){return this}get definition(){return this.getView()}},v=class extends Error{constructor(t){super(`Parameter [${t}] is required.`),this.name=\"FileStorageParameterError\"}},T=class extends Error{constructor(t){super(`File not found: ${t}`),this.name=\"FileStorageFileNotFoundError\"}},A=class extends Error{constructor({message:t,code:e,type:i}={}){super(t),this.name=\"RequestError\",this.code=e,this.type=i}},E=class extends Error{constructor(){super(\"Call loadConfig() first.\"),this.name=\"SettingLoadConfigError\"}},S=class extends Error{constructor(){super(\"Attempted to assign to readonly property.\"),this.name=\"SettingReadonlyError\"}},I=class extends Error{constructor(){super(\"Please call setView(view) first.\"),this.name=\"SheetViewUndefinedError\"}},x=class extends Error{constructor(t,e){super(`The type of the parameter '${t}' must be '${e}'`),this.name=\"ValidationError\"}},C=class extends b{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",m.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height)},this.views=[b.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},k=class extends b{titleStyle={font:$font(\"bold\",21),height:30};#t;#e;templateIdByIndex(t){return this.props.template.views[t]?.props?.id===void 0&&(void 0===this.props.template.views[t].props&&(this.props.template.views[t].props={}),this.props.template.views[t].props.id=$text.uuid),this.props.template.views[t].props.id}get templateHiddenStatus(){if(!this.#e){this.#e={};for(let t=0;t{t.items=t.items.filter(t=>t?.__title?.hidden===!0),e.push(t)}),e}set data(t){this.props.data=this.rebuildData(t),$(this.id).data=this.props.data}#i(t){let e={...this.hiddenViews};return Object.assign(e,{__templateProps:{hidden:!0},__title:{hidden:!1,text:t,info:{title:!0}}}),e}rebuildData(t=[]){return t.map(t=>(t.items=t.items.map(t=>(Object.keys(t).forEach(e=>{t[e].hidden=this.templateHiddenStatus[e]??!1}),Object.keys(this.templateHiddenStatus).forEach(e=>{t[e]||(t[e]={}),t[e].hidden=this.templateHiddenStatus[e]}),t.__templateProps={hidden:!1},t.__title={hidden:!0},t)),t.title&&t.items.unshift(this.#i(t.title)),t))}rebuildTemplate(){let t={};void 0!==this.props.template.props&&(void 0!==this.props.template.props.cornerRadius&&(this.props.template.props.clipsToBounds=!1),t=Object.assign(this.props.template.props,{id:\"__templateProps\",hidden:!1}));let e=[{type:\"view\",props:t,layout:$layout.fill},{type:\"label\",props:{id:\"__title\",hidden:!0,font:this.titleStyle.font},layout:(t,e)=>{t.top.inset(-(3*(this.titleStyle.height/4))),t.height.equalTo(this.titleStyle.height),t.width.equalTo(e.super.safeArea)}}].concat(this.props.template.views);this.props.template.views=e}insert(t,e=!0){return t.indexPath=this.indexPath(t.indexPath,e),$(this.id).insert(t)}delete(t,e=!0){return t=this.indexPath(t,e),$(this.id).delete(t)}object(t,e=!0){return t=this.indexPath(t,e),$(this.id).object(t)}cell(t,e=!0){return t=this.indexPath(t,e),$(this.id).cell(t)}indexPath(t,e){let i=e?1:0;return t=\"number\"==typeof t?$indexPath(0,t+i):$indexPath(t.section,t.row+i)}getView(){return this.props.data=this.rebuildData(this.props.data),this.rebuildTemplate(),this.setEvent(\"itemSize\",(t,e)=>{if(t.object(e)?.__title?.info?.title)return $size(Math.max($device.info.screen.width,$device.info.screen.height),0);let i=this.props.columns??2,s=this.props.spacing??15;return $size(this.props.itemWidth??this.props.itemSize?.width??(t.super.frame.width-s*(i+1))/i,this.props.itemHeight??this.props.itemSize?.height??100)}),this}},D=class extends b{controller={};setController(t){return this.controller=t,this}},B=class t extends b{static #t;edges=15;buttonEdges=this.edges/2;iconSize=24;fontSize=17;color=m.textColor;title;#e;#i;align=m.align.right;get symbol(){return\"string\"==typeof this.#e?\"icon\"===this.#i?$icon(this.#e,this.color):$image(this.#e):this.#e}set symbol(t){\"string\"==typeof this.#e?isNaN(t)?this.#i=\"image\":this.#i=\"icon\":\"[object BBFileIcon]\"===String(t)?this.#i=\"icon\":this.#i=\"image\",this.#e=t}get width(){return this.title?Math.ceil($text.sizeThatFits({text:this.title,width:m.windowSize.width,font:$font(this.fontSize)}).width)+this.edges:this.iconSize+this.edges}static get style(){return void 0===this.#t&&(this.#t=new t),this.#t}setEdges(t){return this.edges=t,this}setFontSize(t){return this.fontSize=t,$(this.id)&&($(this.id).font=$font(this.fontSize)),this}setColor(t=m.textColor){return this.color=t,$(this.id)&&($(this.id).titleColor=this.color,$(`icon-button-${this.id}`).titleColor=this.color,$(`icon-checkmark-${this.id}`).titleColor=this.color),this}setTitle(t){return this.title=t,$(this.id)&&($(this.id).title=this.title),this}setSymbol(t){return this.symbol=t,$(`icon-button-${this.id}`)&&(\"icon\"===this.#i?$(`icon-button-${this.id}`).icon=this.symbol:$(`icon-button-${this.id}`).image=this.symbol),this}setMenu(t){return this.menu=t,this}setAlign(t){return this.align=t,this}setLoading(t){t?($(this.id).hidden=!0,$(\"spinner-\"+this.id).hidden=!1):($(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0)}#s(){let t=$(`icon-button-${this.id}`),e=$(`icon-checkmark-${this.id}`);t.alpha=0,$(this.id).hidden=!1,$(\"spinner-\"+this.id).hidden=!0,$ui.animate({duration:.6,animation:()=>{e.alpha=1},completion:()=>{$delay(.3,()=>$ui.animate({duration:.6,animation:()=>{e.alpha=0},completion:()=>{$ui.animate({duration:.4,animation:()=>{t.alpha=1},completion:()=>{t.alpha=1}})}}))}})}hide(){$(this.id+\"-container\").hidden=!0}show(){$(this.id+\"-container\").hidden=!1}getView(){let t=this.events.tapped;return this.events.tapped=e=>{t&&t({start:()=>this.setLoading(!0),done:()=>this.#s(),cancel:()=>this.setLoading(!1)},e)},{type:\"view\",props:{id:this.id+\"-container\",info:{align:this.align}},views:[{type:\"button\",props:Object.assign({id:this.id,bgcolor:$color(\"clear\"),font:$font(this.fontSize),titleColor:this.color,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},this.menu?{menu:this.menu}:{},this.title?{title:this.title}:{},this.props),views:[{type:\"image\",props:Object.assign({id:`icon-button-${this.id}`,hidden:void 0===this.symbol,tintColor:this.color},this.symbol?\"icon\"===this.#i?{icon:this.symbol}:{image:this.symbol}:{}),layout:(t,e)=>{this.symbol&&\"image\"===this.#i&&t.size.equalTo(m.getSymbolSize(this.symbol,this.iconSize)),t.center.equalTo(e.super)}},{type:\"image\",props:{id:`icon-checkmark-${this.id}`,alpha:0,tintColor:this.color,symbol:\"checkmark\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(m.getSymbolSize(\"checkmark\",this.iconSize))}}],events:this.events,layout:$layout.fill},{type:\"spinner\",props:{id:\"spinner-\"+this.id,loading:!0,hidden:!0},layout:$layout.fill}],layout:(t,e)=>{if(t.size.equalTo($size(this.width,m.NavigationBarNormalHeight)),t.centerY.equalTo(e.super),e.prev&&e.prev?.info?.align===this.align)this.align===m.align.right?t.right.equalTo(e.prev.left).offset(-this.buttonEdges):t.left.equalTo(e.prev.right).offset(this.buttonEdges);else{let e=this.edges/2;this.align===m.align.right?t.right.inset(e):t.left.inset(e)}}}}static creat({id:e,symbol:i,title:s,tapped:n,menu:a,events:r,color:o,align:l=m.align.right}={}){let h=new t;return h.setEvents(Object.assign({tapped:n},r)).setAlign(l).setSymbol(i).setTitle(s).setColor(o).setMenu(a),e&&h.setProp(\"id\",e),h}},O=class t extends b{static largeTitleDisplayModeAutomatic=0;static largeTitleDisplayModeAlways=1;static largeTitleDisplayModeNever=2;navigationBarItems;title=\"\";prefersLargeTitles=!0;largeTitleDisplayMode=t.largeTitleDisplayModeAutomatic;fontFamily=\"bold\";largeTitleFontSize=34;largeTitleFontHeight=$text.sizeThatFits({text:\"A\",width:100,font:$font(this.fontFamily,this.largeTitleFontSize)}).height;navigationBarTitleFontSize=17;topSafeArea=!0;contentViewHeightOffset=0;navigationBarNormalHeight=m.NavigationBarNormalHeight;navigationBarLargeTitleHeight=m.NavigationBarLargeTitleHeight;setTopSafeArea(){return this.topSafeArea=!0,this}removeTopSafeArea(){return this.topSafeArea=!1,this}setLargeTitleDisplayMode(t){return this.largeTitleDisplayMode=t,this}setBackgroundColor(t){return this.backgroundColor=t,this}setTitle(t){return this.title=t,this}setPrefersLargeTitles(t){return this.prefersLargeTitles=t,this}setContentViewHeightOffset(t){return this.contentViewHeightOffset=t,this}getLargeTitleView(){return this.prefersLargeTitles&&this.largeTitleDisplayMode!==t.largeTitleDisplayModeNever?{type:\"label\",props:{id:this.id+\"-large-title\",text:this.title,textColor:m.textColor,align:$align.left,font:$font(this.fontFamily,this.largeTitleFontSize),line:1},layout:(t,e)=>{t.left.equalTo(e.super.safeArea).offset(15),t.height.equalTo(this.largeTitleFontHeight),t.top.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}:{props:{id:this.id+\"-large-title\"},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)}}}getNavigationBarView(){let e=(t,e)=>{let i=(t,i)=>{t.top.equalTo(i.super.safeAreaTop),t.bottom.equalTo(i.super.safeAreaTop).offset(this.navigationBarNormalHeight),e===m.align.left?t.left.equalTo(i.super.safeArea):t.right.equalTo(i.super.safeArea)};if(t&&!Array.isArray(t))return{type:\"view\",views:[t],layout:i};let s=0,n=[];t.forEach(t=>{s+=t.width,n.push(t.definition)});let a=t[0]?.edges??0;return s+=t.length>=2?2*a:a,t.length>0?{type:\"view\",views:n,info:{width:s},layout:(t,e)=>{i(t,e),t.width.equalTo(s)}}:{type:\"view\",layout:t=>t.size.equalTo(0)}},i=e(this.navigationBarItems.popButtonView??this.navigationBarItems.leftButtons,m.align.left),s=e(this.navigationBarItems.rightButtons,m.align.right),n=this.prefersLargeTitles,a=!this.prefersLargeTitles||this.largeTitleDisplayMode===t.largeTitleDisplayModeNever;return{type:\"view\",props:{id:this.id+\"-navigation\",bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.top.right.inset(0),t.bottom.equalTo(e.super.safeAreaTop).offset(this.navigationBarNormalHeight)},views:[this.backgroundColor?{type:\"view\",props:{hidden:n,bgcolor:this.backgroundColor,id:this.id+\"-background\"},layout:$layout.fill}:m.blurBox({hidden:n,id:this.id+\"-background\"}),m.separatorLine({id:this.id+\"-underline\",alpha:n?0:1}),{type:\"view\",props:{alpha:0,bgcolor:$color(\"clear\"),id:this.id+\"-large-title-mask\"},events:{ready:t=>{t.bgcolor=$(this.id+\"-large-title\")?.prev.bgcolor}},layout:$layout.fill},i,s,{type:\"view\",views:[{type:\"label\",props:{id:this.id+\"-small-title\",alpha:a?1:0,text:this.title,font:$font(this.fontFamily,this.navigationBarTitleFontSize),align:$align.center,bgcolor:$color(\"clear\"),textColor:m.textColor},layout:(t,e)=>{t.edges.equalTo(e.super.safeArea);let n=m.getContentSize($font(this.fontFamily,this.navigationBarTitleFontSize),e.text).width,a=Math.max(i.info?.width??0,s.info?.width??0);m.windowSize.width-2*a>n&&t.centerX.equalTo(e.super.super)}}],layout:(t,e)=>{t.top.bottom.equalTo(e.super.safeArea),t.left.equalTo(e.prev.prev.right),t.right.equalTo(e.prev.left)}}]}}},R=class t extends n{static largeTitleViewSmallMode=0;static largeTitleViewLargeMode=1;navigationBar;updateSelector(){this.selector={navigation:$(this.navigationBar.id+\"-navigation\"),largeTitleView:$(this.navigationBar.id+\"-large-title\"),smallTitleView:$(this.navigationBar.id+\"-small-title\"),underlineView:this.navigationBar.navigationBarItems.isPinTitleView?$(this.navigationBar.id+\"-title-view-underline\"):$(this.navigationBar.id+\"-underline\"),largeTitleMaskView:$(this.navigationBar.id+\"-large-title-mask\"),backgroundView:$(this.navigationBar.id+\"-background\"),titleViewBackgroundView:$(this.navigationBar.id+\"-title-view-background\")}}toNormal(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!1,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=1,this.selector.smallTitleView.alpha=1,this.selector.largeTitleView.alpha=0}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=O.largeTitleDisplayModeNever)}toLargeTitle(t=!0){this.updateSelector(),this.selector.backgroundView.hidden=!0,$ui.animate({duration:.2,animation:()=>{this.selector.underlineView.alpha=0,this.selector.smallTitleView.alpha=0,this.selector.largeTitleView.alpha=1}}),t&&this.navigationBar.navigationBarItems&&(this.navigationBar.largeTitleDisplayMode=O.largeTitleDisplayModeAlways)}#t(e){let i=e===t.largeTitleViewSmallMode;this.selector.largeTitleView.alpha=i?0:1,$ui.animate({duration:.2,animation:()=>{this.selector.smallTitleView.alpha=i?1:0}})}#e(e){if(this.selector.largeTitleView.updateLayout((t,i)=>{this.navigationBar.navigationBarNormalHeight-e>0?t.top.equalTo(i.super.safeAreaTop).offset(this.navigationBar.navigationBarNormalHeight-e):t.top.equalTo(i.super.safeAreaTop).offset(0)}),e>0)e>=this.navigationBar.navigationBarNormalHeight?this.#t(t.largeTitleViewSmallMode):this.#t(t.largeTitleViewLargeMode);else{this.#t(t.largeTitleViewLargeMode);let i=this.navigationBar.largeTitleFontSize-.04*e;i>40&&(i=40),this.selector.largeTitleView.font=$font(this.navigationBar.fontFamily,i)}}#i(t){let e=this.navigationBar.largeTitleDisplayMode===O.largeTitleDisplayModeNever?5:this.navigationBar.navigationBarNormalHeight,i=void 0!==this.selector.titleViewBackgroundView;if(t>e){this.selector.backgroundView.hidden=!1;let s=()=>{i&&this.navigationBar.navigationBarItems.isPinTitleView&&(this.selector.titleViewBackgroundView.alpha=1),this.selector.largeTitleMaskView.alpha=0,this.selector.underlineView.alpha=1};(t-e)/3>=1?s():$ui.animate({duration:.2,animation:()=>{s()}})}else this.selector.largeTitleMaskView.alpha=t>0?1:0,this.selector.underlineView.alpha=0,i&&(this.selector.titleViewBackgroundView.alpha=0),this.selector.backgroundView.hidden=!0}didScroll(t){if(!this.navigationBar.prefersLargeTitles)return;let e=this.navigationBar.largeTitleDisplayMode;if(e!==O.largeTitleDisplayModeAlways){if(this.updateSelector(),e===O.largeTitleDisplayModeAutomatic){if(!this.navigationBar.navigationBarItems?.isPinTitleView&&(this.navigationBar.navigationBarItems?.titleView?.controller.didScroll(t),t>0)){let e=this.navigationBar.navigationBarItems?.titleView?.height??0;(t-=e)<0&&(t=0)}this.#e(t),this.#i(t)}else e===O.largeTitleDisplayModeNever&&this.#i(t)}}didEndDragging(t,e,i,s){if(!this.navigationBar.prefersLargeTitles)return;let n=this.navigationBar.largeTitleDisplayMode;if(n!==O.largeTitleDisplayModeAlways&&(this.updateSelector(),n===O.largeTitleDisplayModeAutomatic)){let n=0;this.navigationBar.navigationBarItems?.isPinTitleView||(this.navigationBar.navigationBarItems?.titleView?.controller.didEndDragging(t,e,i,s),n=this.navigationBar.navigationBarItems?.titleView?.height??0,t-=n),t>=0&&t<=this.navigationBar.largeTitleFontHeight&&i($point(0,t>=this.navigationBar.largeTitleFontHeight/2?this.navigationBar.navigationBarNormalHeight+n-s:n-s))}}},L=class extends x{constructor(t,e){super(t,e),this.name=\"NavigationViewTypeError\"}},N=class extends n{page;navigationController=new R;navigationBar=new O;navigationBarItems=new c;constructor(){super(),this.navigationBar.navigationBarItems=this.navigationBarItems,this.navigationController.navigationBar=this.navigationBar}navigationBarTitle(t){return this.navigationBar.setTitle(t),this}setView(t){if(\"object\"!=typeof t)throw new L(\"view\",\"object\");return this.view=b.create(t),this}getTopOffset(){if(!(this.view instanceof b))throw new L(\"view\",\"View\");let t=this.view.scrollableView,e=$app.isDebugging?0:m.topSafeAreaInsets,i=this.navigationBar.largeTitleDisplayMode===O.largeTitleDisplayModeNever?this.navigationBar.navigationBarNormalHeight:this.navigationBar.navigationBarLargeTitleHeight,s=this.navigationBar.contentViewHeightOffset+i;if(this.navigationBarItems.titleView&&(s+=this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset),!this.view.scrollable||!1===t.props.associateWithNavigationBar){let t=s-this.navigationBar.contentViewHeightOffset;return(!m.isHorizontal||m.isLargeScreen)&&this.navigationBar.topSafeArea&&(t+=e),t}return t.props.stickyHeader&&(s-=i,s+=this.navigationBar.largeTitleFontHeight),s}getBottomOffset(){return this.navigationBarItems.fixedFooterView?.height??0}#t(){if(!(this.view instanceof b))throw new L(\"view\",\"View\");let t=this.view.scrollableView,e=$app.isDebugging?0:m.topSafeAreaInsets,i=this.getTopOffset();if(!this.view.scrollable||!1===t.props.associateWithNavigationBar){this.view.layout=(t,e)=>{t.left.right.equalTo(e.super.safeArea),t.bottom.equalTo(e.super),t.top.equalTo(i)};return}let s=this.navigationBarItems.isPinTitleView?this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset+this.navigationBar.contentViewHeightOffset:0;if(t.props.indicatorInsets){let e=t.props.indicatorInsets;t.props.indicatorInsets=$insets(e.top+this.navigationBar.navigationBarNormalHeight+s,e.left,e.bottom+this.getBottomOffset(),e.right)}else t.props.indicatorInsets=$insets(this.navigationBar.navigationBarNormalHeight+s,0,this.navigationBarItems.fixedFooterView?.height??0,0);if(t.props.contentInset){let e=t.props.contentInset;t.props.contentInset=$insets(e.top+i+s,e.left,e.bottom+this.getBottomOffset(),e.right)}else t.props.contentInset=$insets(i+s,0,this.navigationBarItems.fixedFooterView?.height??0,0);t.props.contentOffset=$point(0,-i),t.layout=(e,i)=>{t.props.stickyHeader?e.top.equalTo(i.super.safeArea).offset(this.navigationBar.navigationBarNormalHeight):e.top.equalTo(i.super),e.left.right.equalTo(i.super.safeArea),e.bottom.equalTo(i.super)},t.assignEvent(\"didScroll\",s=>{let n=s.contentOffset.y;(!m.isHorizontal||m.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(n+=e),n+=i,this.navigationController.didScroll(n)}).assignEvent(\"didEndDragging\",(s,n)=>{let a=s.contentOffset.y,r=0;(!m.isHorizontal||m.isLargeScreen)&&this.navigationBar.topSafeArea&&!t.props.stickyHeader&&(a+=e,r=e),a+=i,r+=i,this.navigationController.didEndDragging(a,n,(...t)=>s.scrollToOffset(...t),r)}).assignEvent(\"didEndDecelerating\",(...e)=>{e[0].tracking||t.events?.didEndDragging(...e)})}#e(){if(this.navigationBar.prefersLargeTitles){this.#t();let t={};if(this.navigationBarItems.titleView){let e=this.navigationBar.largeTitleDisplayMode===O.largeTitleDisplayModeNever?1:0;t=b.create({views:[this.navigationBar.backgroundColor?{type:\"view\",props:{alpha:e,bgcolor:this.navigationBar.backgroundColor,id:this.navigationBar.id+\"-title-view-background\"},layout:$layout.fill}:m.blurBox({alpha:e,id:this.navigationBar.id+\"-title-view-background\"}),m.separatorLine({id:this.navigationBar.id+\"-title-view-underline\",alpha:e}),this.navigationBarItems.titleView.definition],layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.width.equalTo(e.super),t.height.equalTo(this.navigationBarItems.titleView.topOffset+this.navigationBarItems.titleView.height+this.navigationBarItems.titleView.bottomOffset)}})}this.page=ta.createFromViews([this.view,this.navigationBar.getLargeTitleView(),t,this.navigationBar.getNavigationBarView(),this.navigationBarItems.fixedFooterView?.definition??{}])}else this.page=ta.createFromViews([this.view]);this.view.props?.bgcolor?this.page.setProp(\"bgcolor\",this.view.props.bgcolor):this.page.setProp(\"bgcolor\",m.defaultBackgroundColor(this.view.type))}getPage(){return this.page||this.#e(),this.page}},P=class extends D{height=35;topOffset=15;bottomOffset=10;horizontalOffset=15;kbType=$kbType.search;placeholder=$l10n(\"SEARCH\");inputEvents={};keyboardView;accessoryView;cancelButtonFont=$font(16);constructor(t){super(t),this.setController(new V),this.controller.setSearchBar(this)}get cancelButtonWidth(){return m.getContentSize(this.cancelButtonFont,$l10n(\"CANCEL\")).width}setEvent(t,e){return this.inputEvents[t]=e,this}setPlaceholder(t){return this.placeholder=t,this}setKbType(t){return this.kbType=t,this}setKeyboardView(t){return this.keyboardView=t,this}setAccessoryView(t){return this.accessoryView=t,this}onBeginEditingAnimate(){$ui.animate({duration:.3,animation:()=>{let t=this.cancelButtonWidth;$(this.id+\"-cancel-button\").updateLayout((e,i)=>{e.left.equalTo(i.super.right).offset(-t)}),$(this.id+\"-cancel-button\").alpha=1,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout(e=>{e.right.inset(t+this.horizontalOffset/2)}),$(this.id+\"-input\").relayout()}})}onEndEditingAnimate(){$ui.animate({duration:.3,animation:()=>{$(this.id+\"-cancel-button\").updateLayout((t,e)=>{t.left.equalTo(e.super.right)}),$(this.id+\"-cancel-button\").alpha=0,$(this.id+\"-cancel-button\").relayout(),$(this.id+\"-input\").updateLayout($layout.fill),$(this.id+\"-input\").relayout()}})}cancel(){$(this.id+\"-input\").blur(),$(this.id+\"-input\").text=\"\",this.onEndEditingAnimate(),this.controller.callEvent(\"onCancel\")}getView(){return this.props={id:this.id,smoothCorners:!0,cornerRadius:6},this.views=[{type:\"input\",props:{id:this.id+\"-input\",type:this.kbType,bgcolor:$color(\"#EEF1F1\",\"#212121\"),placeholder:this.placeholder,keyboardView:this.keyboardView,accessoryView:this.accessoryView},layout:$layout.fill,events:Object.assign({didBeginEditing:t=>{this.onBeginEditingAnimate(),this.controller.callEvent(\"onBeginEditing\",t.text)},didEndEditing:t=>{this.controller.callEvent(\"onEndEditing\",t.text)},changed:t=>this.controller.callEvent(\"onChange\",t.text),returned:t=>this.controller.callEvent(\"onReturn\",t.text)},this.inputEvents)},{type:\"button\",props:{id:this.id+\"-cancel-button\",title:$l10n(\"CANCEL\"),font:this.cancelButtonFont,titleColor:$color(\"tintColor\"),bgcolor:$color(\"clear\"),alpha:0,hidden:!1},events:{tapped:()=>this.cancel()},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(this.cancelButtonWidth),t.left.equalTo(e.super.right)}}],this.layout=(t,e)=>{t.height.equalTo(this.height),t.top.equalTo(e.super.safeArea).offset(this.topOffset),t.left.equalTo(e.super.safeArea).offset(this.horizontalOffset),t.right.equalTo(e.super.safeArea).offset(-this.horizontalOffset)},this}},V=class extends n{setSearchBar(t){return this.searchBar=t,this}updateSelector(){this.selector={inputBox:$(this.searchBar.id),input:$(this.searchBar.id+\"-input\")}}hide(){this.updateSelector(),this.selector.inputBox.updateLayout(t=>{t.height.equalTo(0)})}show(){this.updateSelector(),this.selector.inputBox.updateLayout(t=>{t.height.equalTo(this.searchBar.height)})}didScroll(t){this.updateSelector();let e=this.searchBar.height-t;if(e=e>0?e>this.searchBar.height?this.searchBar.height:e:0,this.selector.inputBox.updateLayout(t=>{t.height.equalTo(e)}),t>0){let e=(this.searchBar.height/2-5-t)/10;this.selector.input.alpha=e}else this.selector.input.alpha=1}didEndDragging(t,e,i){this.updateSelector(),t>=0&&t<=this.searchBar.height&&i($point(0,t>=this.searchBar.height/2?this.searchBar.height:0))}},_=class extends n{#t=[];#e(t){t.callEvent(\"onPop\"),this.callEvent(\"onPop\",t),this.#t.pop()}push(t){let e=this.#t[this.#t.length-1];t.navigationBarItems.addPopButton(e?.navigationBar.title),this.#t.push(t),$ui.push({props:{statusBarStyle:0,navBarHidden:!0},events:{disappeared:()=>{this.#e(t)}},views:[t.getPage().definition],layout:$layout.fill})}},q=class extends p{get isArray(){return Array.isArray(this.default)}async tapped(){let t=this.isArray?this.default[1]:this.default;0===(await $ui.alert({title:this.title,message:t,actions:[{title:$l10n(\"COPY\")},{title:$l10n(\"OK\")}]})).index&&($clipboard.text=t,$ui.toast($l10n(\"COPIED\")))}getView(){return{type:\"view\",props:{selectable:!0,info:{key:this.key}},views:[this.createLineLabel(),{type:\"label\",props:{text:this.isArray?this.default[0]:this.default,align:$align.right,textColor:$color(\"darkGray\")},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(p.edgeOffset),t.width.equalTo(180)}}],layout:$layout.fill}}},M=class extends p{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"switch\",props:{on:this.get(),onColor:$color(\"#00CC00\")},events:{changed:t=>{try{this.set(t.on)}catch(e){throw t.on=!t.on,e}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(p.edgeOffset)}}],layout:$layout.fill}}},F=class extends p{getView(){return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"square.and.pencil\",bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\")},events:{tapped:t=>{let e=$ui.popover({sourceView:t,sourceRect:t.bounds,directions:$popoverDirection.down,size:$size(320,150),views:[{type:\"text\",props:{id:`${this.id}-string`,align:$align.left,text:this.get()},layout:t=>{t.left.right.inset(10),t.top.inset(20),t.height.equalTo(90)}},{type:\"button\",props:{symbol:\"checkmark\",bgcolor:$color(\"clear\"),titleEdgeInsets:10,contentEdgeInsets:0},layout:t=>{t.right.inset(10),t.bottom.inset(25),t.size.equalTo(30)},events:{tapped:()=>{this.set($(`${this.id}-string`).text),e.dismiss()}}}]})}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(0),t.size.equalTo(50)}}],layout:$layout.fill}}},U=class extends p{with({min:t,max:e}={}){return this.options={min:t,max:e},this}getView({min:t,max:e}={}){let i=`${this.id}-label`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"label\",props:{id:i,text:this.get(),align:$align.left},layout:(t,e)=>{t.height.equalTo(e.super),t.right.inset(120)}},{type:\"stepper\",props:{min:t,max:e,value:this.get()},events:{changed:t=>{$(i).text=t.value;try{this.set(t.value)}catch(t){throw $(i).text=this.get(),t}}},layout:(t,e)=>{t.centerY.equalTo(e.prev),t.right.inset(p.edgeOffset)}}],layout:$layout.fill}}},H=class extends p{rightSymbol=\"chevron.right\";buttonId=`${this.id}-button`;start(){$(this.buttonId).alpha=0,$(`${this.buttonId}-spinner`).alpha=1}cancel(){$(this.buttonId).alpha=1,$(`${this.buttonId}-spinner`).alpha=0}done(){$(`${this.buttonId}-spinner`).alpha=0;let t=$(this.buttonId);t.symbol=\"checkmark\",$ui.animate({duration:.6,animation:()=>t.alpha=1,completion:()=>{$ui.animate({duration:.4,animation:()=>t.alpha=0,completion:()=>{t.symbol=this.rightSymbol,$ui.animate({duration:.4,animation:()=>t.alpha=1})}})}})}with({script:t}={}){return this.options={script:t},this}async tapped(){let t={start:()=>this.start(),cancel:()=>this.cancel(),done:()=>this.done()},{script:e}=this.options;\"function\"==typeof e?await e(t):e.startsWith(\"this.method\")?await Function(\"method\",\"animate\",`return async()=>{await ${e.replace(\"this.\",\"\")}(animate)}`)(this.method,t)():await Function(\"animate\",`return async()=>{${e}}`)(t)()}getView(){return{type:\"view\",props:{id:this.id,selectable:!0,info:{key:this.key}},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{id:this.buttonId,symbol:\"chevron.right\",bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},events:{tapped:()=>this.tapped()},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(0),t.height.equalTo(e.super)}},{type:\"spinner\",props:{id:`${this.buttonId}-spinner`,loading:!0,alpha:0},layout:(t,e)=>{t.size.equalTo(15),t.centerY.equalTo(e.super),t.right.equalTo(e.prev)}}],layout:(t,e)=>{t.right.inset(p.edgeOffset),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},j=class extends p{with({items:t,values:e}={}){return Array.isArray(t)&&(t=t.map(t=>$l10n(t))),this.options={items:t,values:e},this}getView({items:t,values:e}={}){t=this.evalValues(t),e=this.evalValues(e);let i=t?.length>0&&e?.length===t?.length;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"tab\",props:{items:t??[],index:i?e.indexOf(this.get()):this.get(),dynamicWidth:!0},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.prev)},events:{changed:t=>{i?this.set(e[t.index]):this.set(t.index)}}}],layout:$layout.fill}}},z=class extends p{with({items:t,values:e,pullDown:i}={}){return Array.isArray(t)&&(t=t.map(t=>$l10n(t))),this.options={items:t,values:e,pullDown:i},this}getView({items:t,values:e,pullDown:i}={}){let s=`${this.id}-label`,n=this.evalValues(t),a=this.evalValues(e),r=n?.length>0&&a?.length===n?.length,o=(t,i)=>{if(r){let t=this.evalValues(e);this.set(t[i])}else this.set(i);$(s).title=t};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"button\",props:{menu:i?{pullDown:!0,asPrimary:!0,items:n.map((t,e)=>({title:t,handler:()=>o(t,e)}))}:void 0,title:r?n[a.indexOf(this.get())]:n[this.get()],titleColor:$color(\"secondaryText\"),bgcolor:$color(\"clear\"),id:s},events:{tapped:()=>{i||$ui.menu({items:this.evalValues(t),handler:o})}},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],layout:(t,e)=>{t.right.inset(p.edgeOffset),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},W=class extends p{get(t=null){let e=super.get(t);return e?\"string\"==typeof e?$color(e):$rgba(e.red,e.green,e.blue,e.alpha):t}getView(){let t=`${this.id}-color`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"view\",props:{id:t,bgcolor:this.get(),circular:!0,borderWidth:1,borderColor:$color(\"#e3e3e3\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(p.edgeOffset),t.size.equalTo(20)}},{type:\"view\",events:{tapped:async()=>{let e=await $picker.color({color:this.get()});this.set(e.components),$(t).bgcolor=$rgba(e.components.red,e.components.green,e.components.blue,e.components.alpha)}},layout:(t,e)=>{t.right.inset(0),t.height.width.equalTo(e.super.height)}}],layout:(t,e)=>{t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},K=class extends p{with({mode:t=2}={}){return this.options={mode:t},this}getView({mode:t=2}={}){let e=e=>{let i=\"\";switch(\"number\"==typeof e&&(e=new Date(e)),t){case 0:i=e.toLocaleTimeString();break;case 1:i=e.toLocaleDateString();break;case 2:i=e.toLocaleString()}return i};return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"label\",props:{id:`${this.id}-label`,color:$color(\"secondaryText\"),text:this.get()?e(this.get()):\"None\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super)}}],events:{tapped:async()=>{let i=this.get(),s=await $picker.date({props:{mode:t,date:i||Date.now()}});this.set(s.getTime()),$(`${this.id}-label`).text=e(s)}},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},G=class extends p{with({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){return this.options={secure:t,kbType:e,saveFunc:i},this}getView({secure:t=!1,kbType:e=$kbType.default,saveFunc:i}={}){void 0===i&&(i=t=>this.set(t));let s=this.id+\"-input\";return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"input\",props:{id:s,type:e,align:$align.right,bgcolor:$color(\"clear\"),textColor:$color(\"secondaryText\"),text:this.get(),font:$font(16),secure:t,accessoryView:m.blurBox({height:44},[m.separatorLine({},m.align.top),{type:\"button\",props:{title:$l10n(\"DONE\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{$(s).blur()}}},{type:\"button\",props:{title:$l10n(\"CANCEL\"),bgcolor:$color(\"clear\"),titleColor:$color(\"primaryText\")},layout:(t,e)=>{t.left.inset(p.edgeOffset),t.centerY.equalTo(e.super)},events:{tapped:()=>{let t=$(s),e=this.get(\"\");t.text!==e&&(t.text=e),t.blur()}}}])},layout:(t,e)=>{t.left.equalTo(e.prev.get(\"label\").right).offset(p.edgeOffset),t.right.inset(p.edgeOffset),t.width.greaterThanOrEqualTo(50),t.height.equalTo(e.super),t.left.priority(10),t.width.priority(10)},events:{didBeginEditing:t=>{t.secure=!1,$app.autoKeyboardEnabled||($app.autoKeyboardEnabled=!0)},returned:t=>{t.blur()},didEndEditing:async e=>{let s=this.get(\"\");i(e.text)||(e.text=s),t&&(e.secure=t)}}}],layout:$layout.fill}}},J=class extends p{getView(){return new G(this).getView({secure:!1,kbType:$kbType.decimal,saveFunc:t=>\"\"!==t&&/^[0-9]+.?[0-9]*$/.test(t)?this.set(Number(t)):($ui.toast($l10n(\"INVALID_VALUE\")),!1)})}},Y=class extends p{with({bgcolor:t=\"#000000\"}={}){return this.options={bgcolor:t},this}getView({bgcolor:t=\"#000000\"}={}){let e=`${this.id}-image`;return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{cornerRadius:8,bgcolor:\"string\"==typeof t?$color(t):t,smoothCorners:!0},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:e,image:$image(this.get()),icon:$icon(this.get()?.slice(5,this.get().indexOf(\".\")),$color(\"#ffffff\")),tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.right.equalTo(e.prev).offset(-5),t.centerY.equalTo(e.super),t.size.equalTo($size(20,20))}}],events:{tapped:()=>{$ui.menu({items:[$l10n(\"JSBOX_ICON\"),$l10n(\"SF_SYMBOLS\"),$l10n(\"IMAGE_BASE64\")],handler:async(t,i)=>{if(0===i){let t=await $ui.selectIcon();this.set(t),$(e).icon=$icon(t.slice(5,t.indexOf(\".\")),$color(\"#ffffff\"))}else(1===i||2===i)&&$input.text({text:\"\",placeholder:t,handler:t=>{if(\"\"===t){$ui.toast($l10n(\"INVALID_VALUE\"));return}this.set(t),1===i?$(e).symbol=t:$(e).image=$image(t)}})}})}},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},X=class extends p{with({view:t,navButtons:e=[]}={}){return this.options={view:t,navButtons:e},this}tapped(){let{view:t,navButtons:e}=this.options;return t=this.evalValues(t,{}),(e=this.evalValues(e)).length>0&&e.map(t=>{if(\"string\"==typeof t.tapped){let e=t.tapped;t.tapped=()=>{this.evalValues(e)}}return t.handler=t.tapped,t}),new Promise((i,s)=>{if(this.setting.isUseJsboxNav){let s={title:this.title,props:t.props??{},views:[t],disappeared:()=>i()};e.length>0&&(s.navButtons=e),m.push(s)}else{let s=new N;s.setView(t).navigationBarTitle(this.title),s.navigationBarItems.addPopButton(),s.navigationBar.setLargeTitleDisplayMode(O.largeTitleDisplayModeNever),this.setting.hasSectionTitle(t)&&s.navigationBar.setContentViewHeightOffset(-10),e.length>0&&s.navigationBarItems.setRightButtons(e),this.setting.viewController.setEvent(\"onPop\",()=>i()),this.setting.viewController.push(s)}})}getView(){return{type:\"view\",props:{id:this.id,selectable:!0,info:{key:this.key}},views:[this.createLineLabel(),{type:\"button\",props:{symbol:\"chevron.right\",bgcolor:$color(\"clear\"),tintColor:$color(\"secondaryText\")},events:{tapped:()=>this.tapped()},layout:(t,e)=>{t.centerY.equalTo(e.super),t.right.inset(p.edgeOffset),t.height.equalTo(e.super)}}],layout:$layout.fill}}},Z=class extends X{with({children:t}={}){return super.with({view:()=>this.setting.getListView(t,{},this.id)}),this.options.children=t,this}},Q=class extends p{getImagePath(t=!1){let e=$text.MD5(this.key)+\".jpg\";return t&&(e=\"compress.\"+e),this.setting.imagePath+e}getImage(t=!1){try{return this.setting.fileStorage.readSync(this.getImagePath(t))}catch(t){if(t instanceof T)return null;throw t}}get(t=null){return this.getImage(!1)??null}getView(){let t=`${this.id}-image`,e=$image(\"questionmark.square.dashed\"),i=e=>async()=>{$(t).hidden=!0,$(`${t}-spinner`).hidden=!1,await $wait(.1);try{await e()}catch(t){$ui.alert({title:$l10n(\"ERROR\"),message:String(t)})}await $wait(.1),$(`${t}-spinner`).hidden=!0,$(t).hidden=!1},s=[{title:$l10n(\"PREVIEW\"),handler:i(()=>{let t=this.getImage(!1);t?g.quickLookImage(t):$ui.toast($l10n(\"NO_IMAGE\"))})},{inline:!0,items:[{title:$l10n(\"SELECT_IMAGE_PHOTO\"),handler:i(async()=>{let e=await $photo.pick({format:\"data\"});if(!e.status||!e.data){if(e?.error?.description!==\"canceled\")throw Error(e?.error?.description);return}let i=m.compressImage(e.data.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e.data),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))})},{title:$l10n(\"SELECT_IMAGE_ICLOUD\"),handler:i(async()=>{let e=await $drive.open();if(!e)return;let i=m.compressImage(e.image);this.setting.fileStorage.write(this.getImagePath(!0),i.jpg(.8)),this.setting.fileStorage.write(this.getImagePath(),e),$(t).image=i,$ui.success($l10n(\"SUCCESS\"))})}]},{title:$l10n(\"CLEAR_IMAGE\"),destructive:!0,handler:i(()=>{this.setting.fileStorage.delete(this.getImagePath(!0)),this.setting.fileStorage.delete(this.getImagePath()),$(t).image=e,$ui.success($l10n(\"SUCCESS\"))})}];return{type:\"view\",props:{id:this.id,selectable:!0},views:[this.createLineLabel(),{type:\"view\",views:[{type:\"image\",props:{id:t,image:this.getImage(!0)?.image??e},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}},{type:\"spinner\",props:{id:`${t}-spinner`,loading:!0,hidden:!0},layout:(t,e)=>{t.size.equalTo(e.prev),t.left.top.equalTo(e.prev)}},{type:\"button\",props:{menu:{pullDown:!0,asPrimary:!0,items:s},bgcolor:$color(\"clear\")},layout:(t,e)=>{t.right.inset(p.edgeOffset),t.centerY.equalTo(e.super),t.size.equalTo($size(30,30))}}],layout:(t,e)=>{t.right.inset(0),t.height.equalTo(p.rowHeight),t.width.equalTo(e.super)}}],layout:$layout.fill}}},tt=class extends n{name;setting={};settingItems={};userData;fileStorage;logger;imagePath;viewController=new _;method={readme:()=>{let t=(()=>{let t=$device.info?.language?.startsWith(\"zh\")?\"README_CN.md\":\"README.md\";try{return __README__[t]??__README__[\"README.md\"]}catch{return $file.read(t)?.string??$file.read(\"README.md\")?.string}})();new g().setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).addNavBar({title:\"README\",popButton:{symbol:\"x.circle\"}}).init().present()}};#t=!1;#e=!1;#i;constructor(t={}){super(),\"function\"==typeof t.set&&\"function\"==typeof t.get?(this.set=t.set,this.getOriginal=t.get,this.setUserData(t.userData??{})):(this.fileStorage=t.fileStorage??new r,this.dataFile=t.dataFile??\"setting.json\"),t.structure?this.setStructure(t.structure):this.setStructurePath(t.structurePath??\"setting.json\"),this.logger=t.logger??new h,this.isUseJsboxNav=t.isUseJsboxNav??!1,this.imagePath=(t.name??\"default\")+\".image/\",this.setName(t.name??$text.uuid)}useJsboxNav(){return this.isUseJsboxNav=!0,this}#s(){if(!this.#e)throw new E}loader(t){let e=null;switch(t.type){case\"info\":e=new q(t);break;case\"switch\":e=new M(t);break;case\"string\":e=new F(t);break;case\"stepper\":e=new U(t).with({min:t.min??1,max:t.max??12});break;case\"script\":e=new H(t).with({script:t.script??t.value});break;case\"tab\":e=new j(t).with({items:t.items,values:t.values});break;case\"menu\":e=new z(t).with({items:t.items,values:t.values,pullDown:t.pullDown??!1});break;case\"color\":e=new W(t);break;case\"date\":e=new K(t).with({mode:t.mode});break;case\"input\":e=new G(t).with({secure:t.secure});break;case\"number\":e=new J(t);break;case\"icon\":e=new Y(t).with({bgcolor:t.bgcolor});break;case\"push\":e=new X(t).with({view:t.view,navButtons:t.navButtons});break;case\"child\":e=new Z(t).with({children:t.children});break;case\"image\":e=new Q(t);break;default:(e=t).default=t.value,e.get=(...t)=>this.get(...t),e.set=(...t)=>this.set(...t)}return e}loadConfig(){this.#e=!1;let t=this.userData??this.fileStorage.readAsJSON(this.dataFile,{}),e=i=>{for(let s in i)for(let n in i[s].items){let a=i[s].items[n];a instanceof p||(i[s].items[n]=this.loader(a),a=i[s].items[n]),a.setting||(a.setting=this),this.settingItems[a.key]=a,a instanceof Z?e(a.options.children):a instanceof H||a instanceof q||(a.key in t?this.setting[a.key]=t[a.key]:this.setting[a.key]=a.default)}};return e(this.structure),this.#e=!0,this}hasSectionTitle(t){return this.#s(),!!t[0]?.title}setUserData(t){return this.userData=t,this}setStructure(t){return this.structure=t,this.loadConfig()}setStructurePath(t){return this.structure||this.setStructure(r.readFromRootAsJSON(t)),this}setName(t){return this.name=t,this}set footer(t){this.#i=t}get footer(){if(void 0===this.#i){let t=r.readFromRootAsJSON(\"config.json\",{}).info??{};if(!t.version||!t.author)try{t=__INFO__}catch{}this.#i={},t.version&&t.author&&(this.#i={type:\"view\",props:{height:70},views:[{type:\"label\",props:{font:$font(14),text:`${$l10n(\"VERSION\")} ${t.version} \\u2665 ${t.author}`,textColor:$color({light:\"#C0C0C0\",dark:\"#545454\"}),align:$align.center},layout:t=>{t.left.right.inset(0),t.top.inset(10)}}]})}return this.#i}setFooter(t){return this.footer=t,this}setReadonly(){return this.#t=!0,this}set(t,e){if(this.#t)throw new S;return this.#s(),this.setting[t]=e,this.fileStorage.write(this.dataFile,$data({string:JSON.stringify(this.setting)})),this.callEvent(\"onSet\",t,e),!0}getOriginal(t,e=null){return this.#s(),Object.prototype.hasOwnProperty.call(this.setting,t)?this.setting[t]:e}getItem(t){return this.settingItems[t]}get(t,e=null){return this.#s(),this.getItem(t) instanceof p?this.getItem(t).get(e):this.getOriginal(t,e)}#n(t){let e=[];for(let i in t){let s=[];for(let e in t[i].items){let n=t[i].items[e];n instanceof p&&s.push(n.create())}e.push({title:$l10n(t[i].title??\"\"),rows:s})}return e}getListView(t=this.structure,e=this.footer,i=this.name){return{type:\"list\",props:{id:i,style:2,separatorInset:$insets(0,p.iconSize+2*p.edgeOffset,0,p.edgeOffset),footer:e,data:this.#n(t)},layout:$layout.fill,events:{rowHeight:(t,e)=>(t.object(e)?.props?.info??{}).rowHeight??p.rowHeight,didSelect:async(t,e,i)=>{t=t.ocValue();let s=this.getItem(i.props.info.key);if(\"function\"==typeof s?.tapped){t.$selectRowAtIndexPath_animated_scrollPosition(e.ocValue(),!1,0);try{await s.tapped()}catch(t){this.logger.error(t)}}t.$deselectRowAtIndexPath_animated(e,!0)}}}}getNavigationView(){let t=new N;return t.setView(this.getListView(this.structure)).navigationBarTitle($l10n(\"SETTING\")),this.hasSectionTitle(this.structure)&&t.navigationBar.setContentViewHeightOffset(-10),t}getPage(){return this.getNavigationView().getPage()}},te=class extends x{constructor(t,e){super(t,e),this.name=\"SheetViewTypeError\"}},ti=class extends b{constructor(t={}){super(t),this.setIcon(t.icon),this.setTitle(t.title),void 0!==t.activeStatus&&(this.activeStatus=t.activeStatus)}setIcon(t){return t instanceof Array?this.icon=t:this.icon=[t,t],this}setTitle(t){return this.title=t,this}active(){$(`${this.props.id}-icon`).image=$image(this.icon[1]),$(`${this.props.id}-icon`).tintColor=$color(\"systemLink\"),$(`${this.props.id}-title`).textColor=$color(\"systemLink\"),this.activeStatus=!0}inactive(){$(`${this.props.id}-icon`).image=$image(this.icon[0]),$(`${this.props.id}-icon`).tintColor=$color(\"lightGray\"),$(`${this.props.id}-title`).textColor=$color(\"lightGray\"),this.activeStatus=!1}getView(){return this.views=[{type:\"image\",props:{id:`${this.props.id}-icon`,image:$image(this.activeStatus?this.icon[1]:this.icon[0]),bgcolor:$color(\"clear\"),tintColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.super);let i=tn.tabBarHeight/2;t.size.equalTo(i),t.top.inset((tn.tabBarHeight-i-13)/2)}},{type:\"label\",props:{id:`${this.props.id}-title`,text:this.title,font:$font(10),textColor:$color(this.activeStatus?\"systemLink\":\"lightGray\")},layout:(t,e)=>{t.centerX.equalTo(e.prev),t.top.equalTo(e.prev.bottom).offset(3)}}],this}},ts=class extends b{height=60;getView(){return this.type=\"view\",this.setProp(\"bgcolor\",this.props.bgcolor??m.primaryViewBackgroundColor),this.layout=(t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.height-tn.tabBarHeight)},this.views=[b.create({props:this.props,views:this.views,layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.height.equalTo(this.height)}})],this}},tn=class t extends n{static tabBarHeight=50;#t={};#e={};#i;#s;#n=$text.uuid;#a=$text.uuid;bottomSafeAreaInsets=$app.isDebugging?0:m.bottomSafeAreaInsets;get selected(){return this.#s}set selected(t){this.switchPageTo(t)}get contentOffset(){return t.tabBarHeight+(this.#i?.height??0)}setPages(t={}){return Object.keys(t).forEach(e=>this.setPage(e,t[e])),this}setPage(t,e){return void 0===this.#s&&(this.#s=t),e instanceof ta?this.#t[t]=e:this.#t[t]=ta.create(e),this.#s!==t&&(this.#t[t].activeStatus=!1),this}switchPageTo(t){this.#t[t]&&this.#s!==t&&($ui.animate({duration:.4,animation:()=>{this.#e[t].active()}}),this.#e[this.#s].inactive(),this.#t[this.#s].hide(),this.#t[t].show(),this.callEvent(\"onChange\",this.#s,t),this.#s=t,this.initBackground())}hideBackground(t=!0){$(this.#a).hidden=!0,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#n).alpha=0}})}showBackground(t=!0){$(this.#a).hidden=!1,$ui.animate({duration:t?.2:1e-4,animation:()=>{$(this.#n).alpha=1}})}initBackground(){let t=this.#t[this.selected];t.scrollable&&$delay(0,()=>{let e=$(t.id).get(t.scrollableView.id),i=e.contentOffset.y;e.contentSize.height+this.bottomSafeAreaInsets-e.frame.height-i<=0?this.hideBackground(!1):this.showBackground(!1)})}setCells(t={}){return Object.keys(t).forEach(e=>this.setCell(e,t[e])),this}setCell(t,e){return void 0===this.#s&&(this.#s=t),e instanceof ti||(e=new ti({props:{info:{key:t}},icon:e.icon,title:e.title,activeStatus:this.#s===t})),this.#e[t]=e,this}setHeader(t){return this.#i=t,this}#r(){let t=[];return Object.values(this.#e).forEach(e=>{e.setEvent(\"tapped\",t=>{let e=t.info.key;this.switchPageTo(e)}),t.push(e.getView())}),t}#o(){return Object.values(this.#t).map(t=>{if(t.scrollable){let e=t.scrollableView;if(e.props.indicatorInsets){let t=e.props.indicatorInsets;e.props.indicatorInsets=$insets(t.top,t.left,t.bottom+this.contentOffset,t.right)}else e.props.indicatorInsets=$insets(0,0,this.contentOffset,0);if(e.props.contentInset){let t=e.props.contentInset;e.props.contentInset=$insets(t.top,t.left,t.bottom+this.contentOffset,t.right)}else e.props.contentInset=$insets(0,0,this.contentOffset,0);\"function\"==typeof e.assignEvent&&e.assignEvent(\"didScroll\",t=>{let e=t.contentOffset.y-this.contentOffset;t.contentSize.height+this.bottomSafeAreaInsets-t.frame.height-e<=1?this.hideBackground():this.showBackground()})}return t.definition})}generateView(){let e={type:\"view\",layout:(e,i)=>{e.centerX.equalTo(i.super),e.width.equalTo(i.super),e.top.equalTo(i.super.safeAreaBottom).offset(-t.tabBarHeight),e.bottom.equalTo(i.super)},views:[m.blurBox({id:this.#n}),{type:\"stack\",layout:$layout.fillSafeArea,props:{axis:$stackViewAxis.horizontal,distribution:$stackViewDistribution.fillEqually,spacing:0,stack:{views:this.#r()}}},m.separatorLine({id:this.#a},m.align.top)],events:{ready:()=>this.initBackground()}};return b.createFromViews(this.#o().concat(this.#i?.definition??[],e))}},ta=class extends b{constructor(t={}){super(t),this.activeStatus=!0}show(){$(this.props.id).hidden=!1,this.activeStatus=!0}hide(){$(this.props.id).hidden=!0,this.activeStatus=!1}setHorizontalSafeArea(t){return this.horizontalSafeArea=t,this}#t(t,e){t.top.bottom.equalTo(e.super),this.horizontalSafeArea?t.left.right.equalTo(e.super.safeArea):t.left.right.equalTo(e.super)}getView(){return this.layout=this.#t,this.props.clipsToBounds=!0,this.props.hidden=!this.activeStatus,super.getView()}},tr=class extends u{#t;user;password;#e;namespace=\"JSBox.WebDAV\";lockTokenCacheKey=this.namespace+\".lockToken\";get host(){return this.#t}set host(t){for(this.#t=t.trim();this.#t.endsWith(\"/\");)this.#t=this.#t.substring(0,this.#t.length-1);this.#t.startsWith(\"http\")||(this.#t=\"http://\"+this.#t)}get basepath(){return this.#e}set basepath(t){for(this.#e=t.trim();this.#e.endsWith(\"/\");)this.#e=this.#e.substring(0,this.#e.length-1);for(;this.#e.startsWith(\"/\");)this.#e=this.#e.substring(1);this.#e=\"/\"+this.#e}constructor({host:t,user:e,password:i,basepath:s=\"\"}={}){super(),this.host=t,this.user=e,this.password=i,this.basepath=s}#i(t){return t=(t=t.trim()).startsWith(\"/\")?t:\"/\"+t,this.basepath+t}async request(t,e,i=null,s={}){return s=Object.assign({\"Content-Type\":\"text/xml; charset=UTF-8\",Authorization:\"Basic \"+$text.base64Encode(`${this.user}:${this.password}`)},s),await super.request(this.host+this.#i(t),e,i,s)}async allow(t){let e=await this.request(t,u.method.options);return(e.response.headers?.allow??e.response.headers?.Allow)?.split(\",\").map(t=>t.trim().toUpperCase())??[]}async propfind(t,e=[],i=0){Array.isArray(e)||(e=[e]);let s=`${e.map(t=>``).join()}`,n=await this.request(t,\"PROPFIND\",s,{Depth:i});return $xml.parse({string:n.data})}async propfindAll(t,e=0){let i=await this.request(t,\"PROPFIND\",'',{Depth:e});return $xml.parse({string:i.data})}async ls(t,e=1){let i=await this.request(t,\"PROPFIND\",null,{Depth:e});return $xml.parse({string:i.data})}async exists(t){try{return(await this.allow(t)).includes(u.method.get)?await this.request(t,u.method.head):await this.ls(t,0),!0}catch(t){if(t?.code===404)return!1;throw t}}async mkdir(t){return await this.request(t,\"MKCOL\")}async get(t){return await this.request(t,u.method.get,null)}async put(t,e,{withLock:i=!0,waitInterval:s=2,maxTry:n=3}={}){let a={};for(;await this.isLocked(t);){if(--n<=0)throw Error(\"Resource Locked\");await $wait(s)}if(i)try{await this.lock(t),a.If=`(${this.#n(t)})`}catch(t){if(404!==t.code)throw t;i=!1}await this.request(t,u.method.put,e,a),i&&await this.unlock(t)}async delete(t){if(!t)throw Error(\"path empty\");return await this.request(t,u.method.delete)}#s(t,e){let i=$cache.get(this.lockTokenCacheKey)??{};i[t]=e,$cache.set(this.lockTokenCacheKey,i)}#n(t){return($cache.get(this.lockTokenCacheKey)??{})[t]}async isSupportLock(t){try{return!!(await this.propfind(t,\"supportedlock\")).rootElement.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:supportedlock/D:lockentry\"}).firstChild({xPath:\"//D:locktype/D:write\"})}catch(t){if(404!==t.code)return!1;throw t}}async lock(t,{infinity:e=!1,timeout:i=\"Second-10\"}={}){if(!await this.isSupportLock(t))throw Error(\"Your WebDAV service does not support the `LOCK` method.\");let s=`${this.namespace}`,n=await this.request(t,\"LOCK\",s,{Timeout:i,Depth:e?\"infinity\":0}),a=n.response.headers[\"lock-token\"]??n.response.headers[\"Lock-Token\"];return this.#s(t,a),$xml.parse({string:n.data})}async isLocked(t){try{let e=(await this.propfind(t,\"lockdiscovery\")).rootElement;if(e.firstChild({xPath:\"//D:response/D:propstat/D:status\"}).string.includes(\"404\"))await this.lock(t,{timeout:\"Second-0\"});else{let i=e.firstChild({xPath:\"//D:response/D:propstat/D:prop/D:lockdiscovery\"}).children()??[];for(let e=0;e$objc_clean()}),this.fileStorage=g.fileStorage,this.logger=new r,this.logger.setWriter(this.fileStorage,this.logFilePath),this.setting=new l({logger:this.logger,fileStorage:this.fileStorage,structure:c}),this.initComponents()}get storage(){return this.#l||(this.logger.info(\"init storage\"),this.#l=new d(this)),this.#l}get isWebdavEnabled(){return this.setting.get(\"webdav.status\")}initComponents(){this.clips=new u(this),this.actions=new p(this),this.fileManager=new h}}t.exports={AppKernelBase:g}}),a(\"2EAPF\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.SettingInfo,r=i.SettingScript,o=i.SettingTab,l=n(\"1tFrB\"),h=n(\"fEWdA\");let c={items:[new r({icon:[\"folder.fill\",\"#FF9900\"],title:\"FILE_MANAGEMENT\"}).with({script:\"this.method.fileManager\"})].concat(s.isTaio?[]:[new o({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"mainUIDisplayMode\",value:0}).with({items:[\"CLASSIC\",\"MODERN\"]}).onSet(()=>$delay(.3,()=>$addin.restart()))])},d={items:[new a({icon:[\"icon_177\",\"black\"],title:\"Github\",value:[\"ipuppet/CAIO\",\"https://github.com/ipuppet/CAIO\"]}),new a({icon:[\"icon_172\",\"#1888bf\"],title:\"Telegram\",value:[\"JSBoxTG\",\"https://t.me/JSBoxTG\"]}),new a({icon:[\"person.fill\",\"#FF9900\"],title:\"AUTHOR\",value:[\"ipuppet\",\"https://blog.ultagic.com\"]}),new r({icon:\"arrow.2.circlepath\",title:\"CHECK_UPDATE\"}).with({script:\"this.method.checkUpdate\"}),new r({icon:[\"book.fill\",\"#A569BD\"],title:\"README\"}).with({script:\"this.method.readme\"})]};t.exports=[l,c,h,d]}),a(\"1tFrB\",function(t,e){var i=n(\"gxpqj\").UIKit,s=n(\"3dE3D\"),a=n(\"2jPf3\"),r=n(\"iN4Y6\"),o=n(\"knZRr\"),l=n(\"aziQd\"),h=n(\"5xoIG\");t.exports={items:[s,a,r].concat(i.isTaio?[]:[o,l,h])}}),a(\"3dE3D\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingScript,r=i.SettingNumber,o=i.SettingPush,l=i.SettingChild;t.exports=new l({icon:[\"doc.on.clipboard\",\"#FFCC66\"],title:\"CLIPS\"}).with({children:[{items:[new s({icon:[\"link\",\"#FF6633\"],title:\"UNIVERSAL_CLIPBOARD\",key:\"clipboard.universal\",value:!0}),new a({icon:[\"cursorarrow.rays\",\"#FF6633\"],title:\"Tips\"}).with({script:\"$ui.alert({title:$l10n('UNIVERSAL_CLIPBOARD'),message:$l10n('UNIVERSAL_CLIPBOARD_TIPS')})\"})]},{items:[new o({icon:[\"trash\",\"red\"],title:\"RECYCLE_BIN\",key:\"clipboard.recycleBin\"}).with({view:\"this.method.recycleBin\",navButtons:\"this.method.recycleBinNavButtons\"})]},{items:[new r({icon:[\"text.alignleft\",\"#FFCC66\"],title:\"MAX_ITEM_LENGTH\",key:\"clipboard.maxItemLength\",value:100}),new s({icon:[\"square.and.arrow.down.on.square\",\"#FF6633\"],title:\"AUTO_SAVE\",key:\"clipboard.autoSave\",value:!0})]},{items:[new a({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportClipboard\"}),new a({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importClipboard\"})]},{items:[new a({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_DATABASE\"}).with({script:\"this.method.rebuildDatabase\"}),new a({icon:[\"trash\",\"red\"],title:\"DELETE_ALL_DATA\"}).with({script:\"this.method.deleteAllData\"})]}]})}),a(\"2jPf3\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingScript,a=i.SettingChild;t.exports=new a({icon:[\"bolt.circle\",\"#FF6633\"],title:\"ACTIONS\"}).with({children:[{items:[new s({icon:[\"bolt.circle\",\"#FF6633\"],title:\"IMPORT_EXAMPLE_ACTIONS\",value:\"this.method.importExampleAction\"}).with({script:\"this.method.importExampleAction\"})]},{items:[new s({icon:\"square.and.arrow.up\",title:\"EXPORT\"}).with({script:\"this.method.exportAction\"}),new s({icon:[\"square.and.arrow.down\",\"#FFCC33\"],title:\"IMPORT\"}).with({script:\"this.method.importAction\"})]},{items:[new s({icon:[\"square.and.pencil\",\"blue\"],title:\"DEIT_CATEGORY\"}).with({script:\"this.method.editCategory\"})]},{items:[new s({icon:[\"arrow.2.circlepath\",\"red\"],title:\"REBUILD_ACTION_DATABASE\"}).with({script:\"this.method.rebuildAction\"})]}]})}),a(\"iN4Y6\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingInput,r=i.SettingNumber,o=i.SettingChild;t.exports=new o({icon:[\"pencil.circle\",\"#CC0099\"],title:\"EDITOR\"}).with({children:[{title:\"CLIPS\",items:[new r({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"TEXT_INSETS\",key:\"editor.text.insets\",value:300})]},{title:\"CODE\",items:[new s({icon:[\"list.number\",\"#6699CC\"],title:\"SHOW_LINE_NUMBER\",key:\"editor.code.lineNumbers\",value:!1}),new a({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"LIGHT_MODE_THEME\",key:\"editor.code.lightTheme\",value:\"atom-one-light\"}),new a({icon:[\"wand.and.stars\",\"#FF6633\"],title:\"DARK_MODE_THEME\",key:\"editor.code.darkTheme\",value:\"atom-one-dark\"})]}]})}),a(\"knZRr\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingStepper,r=i.SettingScript,o=i.SettingTab,l=i.SettingNumber,h=i.SettingPush,c=i.SettingChild,d=i.SettingImage;t.exports=new c({icon:[\"keyboard\",\"#a2a5a6\"],title:\"KEYBOARD\"}).with({children:[{items:[new h({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\",key:\"keyboard.previewAndHeight\",value:267}).with({view:\"this.method.previewKeyboard\"})]},{items:[new o({icon:[\"rectangle.topthird.inset.filled\",\"#A569BD\"],title:\"DISPLAY_MODE\",key:\"keyboard.displayMode\",value:0}).with({items:[\"LIST\",\"MATRIX\"]}),new l({icon:[\"textformat.size\"],title:\"FONT_SIZE\",key:\"keyboard.fontSize\",value:16}),new s({icon:[\"checkerboard.rectangle\",\"#1899c4\"],title:\"USE_BLUR\",key:\"keyboard.blur\",value:!1}),new d({icon:[\"photo\",\"#FFCC66\"],title:\"BACKGROUND_IMAGE\",key:\"keyboard.background.image\"})]},{items:[new r({icon:[\"pin\",\"#FFCC33\"],title:\"PIN_ACTION\"}).with({script:\"this.method.keyboardPinAction\"})]},{items:[new s({icon:[\"globe\",\"#1899c4\"],title:\"SWITCH_AFTER_INSERT\",key:\"keyboard.switchAfterInsert\",value:!1}),new s({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE\",key:\"keyboard.tapticEngine\",value:!0}),new a({icon:[\"cursor.rays\",\"#FF8C00\"],title:\"TAPTIC_ENGINE_LEVEL\",key:\"keyboard.tapticEngineLevel\",value:1}).with({min:0,max:2}),new r({icon:\"paperplane\",title:\"QUICK_START_SCRIPTS\"}).with({script:\"this.method.setKeyboardQuickStart\"})]},{items:[new l({icon:[\"rays\",\"#FFCC33\"],title:\"DELETE_DELAY\",key:\"keyboard.deleteDelay\",value:.05})]}]})}),a(\"aziQd\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingScript,a=i.SettingMenu,r=i.SettingChild;t.exports=new r({icon:[\"rectangle.3.offgrid.fill\",\"#1899c4\"],title:\"WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewWidget\"})]},{title:\"2x2\",items:[new a({icon:\"link\",title:\"CLICK_ACTION\",key:\"widget.2x2.widgetURL\",value:2}).with({pullDown:!0,items:[\"ADD\",\"ACTIONS\",\"CLIPS\"]})]}]})}),a(\"5xoIG\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingScript,a=i.SettingChild;t.exports=new a({icon:[\"filemenu.and.selection\",\"#ebcc34\"],title:\"TODAY_WIDGET\"}).with({children:[{items:[new s({icon:\"rectangle.3.offgrid.fill\",title:\"PREVIEW\"}).with({script:\"this.method.previewTodayWidget\"})]},{items:[new s({icon:\"bolt.circle\",title:\"ACTIONS\"}).with({script:\"this.method.setTodayWidgetActions\"})]}]})}),a(\"fEWdA\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.SettingChild;let r=[{items:[n(\"fiqsI\")]}];if(!s.isTaio){let t=n(\"fOPZH\");r.push({items:[t]})}t.exports={items:[new a({icon:\"wrench.and.screwdriver\",title:\"EXPERIMENTAL\"}).with({children:r})]}}),a(\"fiqsI\",function(t,e){var i=n(\"gxpqj\"),s=i.SettingSwitch,a=i.SettingInput,r=i.SettingChild;t.exports=new r({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\"}).with({children:[{items:[new s({icon:[\"cloud\",\"#FF9900\"],title:\"WebDAV\",key:\"webdav.status\",value:!1})]},{items:[new a({icon:\"link\",title:\"HOST\",key:\"webdav.host\",value:\"\"}),new a({icon:\"person\",title:\"USER\",type:\"input\",key:\"webdav.user\",value:\"\"}),new a({icon:\"person.badge.key\",title:\"PASSWORD\",type:\"input\",key:\"webdav.password\",value:\"\"}),new a({icon:\"link\",title:\"BASEPATH\",type:\"input\",key:\"webdav.basepath\",value:\"\"})]}]})}),a(\"fOPZH\",function(t,e){var i=n(\"gxpqj\").SettingScript;t.exports=new i({icon:[\"square.and.arrow.up\",\"#FF9900\"],title:\"ADD_TO_TAIO\"}).with({script:()=>{$ui.alert({title:$l10n(\"ADD_TO_TAIO\"),message:$l10n(\"SELECT_TAIO_APP\")}),$share.sheet([{name:\"CAIO.json\",data:$file.read(\"dist/CAIO.json\")}])}})}),a(\"jEwwi\",function(t,e){var i=n(\"gxpqj\").UIKit,s=n(\"7GYtH\");class a{fileStorage;fsPath;imagePath;#h;static isImage(t=\"\"){return t?.startsWith(\"@image=\")}static pathToKey(t){return t=JSON.stringify(t),`@image=${t}`}static keyToPath(t){return!!a.isImage(t)&&JSON.parse(t.slice(7))}constructor({uuid:t,section:e,text:i=\"\",tag:s=null,prev:n=null,next:a=null}={}){if(!t)throw Error(\"Clip create faild: uuid undefined\");if(!e)throw Error(\"Clip create faild: section undefined\");this.uuid=t,this.section=e,this.text=i,this.tag=s,this.prev=n,this.next=a}get text(){return this.#h}set text(t){this.#h=t,a.isImage(t)&&this.#c(a.keyToPath(t))}get hasTag(){return null!==this.tag}get image(){return a.isImage(this.text)}get imageOriginal(){return this.#d(\"original\")}get imagePreview(){return this.#d(\"preview\")}#d(t){if(this.image&&this.fileStorage.exists(this.fsPath[t]))return this.fileStorage.readSync(this.fsPath[t])}#c(t){this.fileStorage&&(this.fsPath=t,this.imagePath={original:this.fileStorage.filePath(t.original),preview:this.fileStorage.filePath(t.preview)})}}class r{sqlite;constructor(t){this.kernel=t,this.dbName=\"CAIO.db\",this.localDb=`/${this.dbName}`;let e=\"/image\";this.imagePath={base:e,original:`${e}/original`,preview:`${e}/preview`},this.tempPath=\"/temp\",this.tempDbFile=`${this.tempPath}/${this.dbName}`,this.tempImagePath=`${this.tempPath}/image`,this.exportFileName=\"CAIO.zip\",this.initWebdavSync(),this.init()}async initWebdavSync(){if(this.kernel.isWebdavEnabled)try{this.webdavSync=new s({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.logger.error(t),t}}needUpload(){this.webdavSync&&this.webdavSync.needUpload()}sync(){this.webdavSync&&this.webdavSync.sync()}init(){this.sqlite&&this.sqlite.close();let t=this.kernel.fileStorage.filePath(this.localDb);$file.exists(t)||$file.write({data:$data({string:\"\"}),path:this.kernel.fileStorage.filePath(this.localDb)}),this.sqlite=$sqlite.open(this.kernel.fileStorage.filePath(this.localDb)),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS clips(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS favorite(uuid TEXT PRIMARY KEY NOT NULL, text TEXT, prev TEXT, next TEXT)\"),this.sqlite.update(\"CREATE TABLE IF NOT EXISTS tag(uuid TEXT PRIMARY KEY NOT NULL, tag TEXT)\"),this.kernel.logger.info(\"init database\")}rebuild(){let t=this.tempPath+\"/rebuild.db\";this.kernel.fileStorage.delete(t);let e=new r(this.kernel);e.localDb=t,e.init();let i=(t,i)=>{let s=[];t.forEach(t=>{let n=new a({uuid:t.uuid,text:t.text,section:t.section,tag:t.tag,prev:null,next:s[0]?.uuid??null});e.beginTransaction();try{e.insert(n),n.next&&(s[0].prev=n.uuid,s[0].section=i,e.update(s[0])),e.commit(),s.unshift(n)}catch(t){throw e.rollback(),this.kernel.logger.error(t),t}})};[\"clips\",\"favorite\"].map(t=>{let e=this.all(t);try{let t=this.sort(e);if(t.length>e.length)throw Error();e=t.reverse()}catch{}i(e,t)});let s=this.sqlite.query(\"SELECT * FROM tag\");this.parseTag(s).forEach(t=>{e.beginTransaction();try{e.setTag(t.uuid,t.tag),e.commit()}catch(t){throw e.rollback(),this.kernel.logger.error(t),t}}),this.kernel.fileStorage.copy(t,this.localDb),this.needUpload(),this.kernel.logger.info(\"database rebuild\")}deleteAllData(){this.kernel.fileStorage.delete(this.imagePath.base),this.kernel.fileStorage.delete(this.localDb),this.needUpload(),this.kernel.logger.info(\"delete all database\")}clearTemp(){this.kernel.fileStorage.delete(this.tempPath)}async export(t){this.clearTemp(),this.kernel.fileStorage.copy(this.localDb,this.tempDbFile),this.kernel.fileStorage.copy(this.imagePath.base,this.tempImagePath);let e=this.tempPath+\"/\"+this.exportFileName;await $archiver.zip({directory:this.kernel.fileStorage.filePath(this.tempPath),dest:this.kernel.fileStorage.filePath(e)}),$share.sheet({items:[{name:this.exportFileName,data:$data({path:this.kernel.fileStorage.filePath(e)})}],handler:i=>{this.kernel.fileStorage.delete(e),t(i)}})}async import(t){if(\"db\"===t.fileName.slice(-2)){if(!this.kernel.fileStorage.writeSync(this.localDb,t))throw Error($l10n(\"WRITE_DB_FILE_FAILED\"))}else if(\"zip\"===t.fileName.slice(-3)){if(!await $archiver.unzip({file:t,dest:this.kernel.fileStorage.filePath(this.tempPath)}))throw Error($l10n(\"UNZIP_FAILED\"));this.kernel.fileStorage.move(this.tempDbFile,this.localDb),this.kernel.fileStorage.move(this.tempImagePath,this.imagePath.base)}this.webdavSync&&this.webdavSync.updateLocalTimestamp()}sort(t,e=9e3){let i={},s=0,n=null;t.forEach(t=>{i[t.uuid]=t,null===t.prev&&(n=t.uuid),s++});let a=[];if(s>0)try{let t=i[n];for(;null!==t.next&&e>0;)e--,a.push(t),t=i[t.next];a.push(t)}catch(t){throw\"Unable to sort: \"+t}return a}replaceString(t){return[\"\\\\\",'\"',\"'\",\"%\",\"-\",\"_\",\";\"].forEach(e=>{t=t.replaceAll(e,`\\\\${e}`)}),t}replaceQuotation(t){return[\"\\\\\",'\"',\"'\"].forEach(e=>{t=t.replaceAll(e,`\\\\${e}`)}),t}parse(t){let e=t.result,i=t.error,s=[];try{if(null!==i)throw Error(`Code [${i.code}] ${i.domain} ${i.localizedDescription}`);for(;e.next();){let t=e.get(\"text\"),i=new a({uuid:e.get(\"uuid\"),section:e.get(\"section\"),tag:e.get(\"tag\"),prev:e.get(\"prev\"),next:e.get(\"next\")});a.isImage(t)&&(i.fileStorage=this.kernel.fileStorage),i.text=t,s.push(i)}}catch(t){throw t}finally{e?.close()}return s}parseTag(t){if(null!==t.error)throw t.error;let e=[];for(;t.result.next();)e.push({uuid:t.result.get(\"uuid\"),tag:t.result.get(\"tag\")});return t.result.close(),e}beginTransaction(){this.sqlite.beginTransaction()}commit(){this.sqlite.commit()}rollback(){this.sqlite.rollback()}getByUUID(t=\"\"){t=this.replaceQuotation(t);let e=this.sqlite.query({sql:`\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE uuid = \"${t}\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE uuid = \"${t}\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `});return this.parse(e)[0]}getByText(t=\"\"){t=this.replaceQuotation(t);let e=this.sqlite.query({sql:`\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE text = \"${t}\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text = \"${t}\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `});return this.parse(e)[0]}async search(t){let e=(await $text.tokenize({text:t})).map(t=>this.replaceString(t)),i=`%${e.join(\"%\")}%`,s=this.sqlite.query({sql:`\n SELECT a.*, tag from\n (SELECT *, 'clips' AS section FROM clips WHERE text like \"${i}\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \"${i}\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `});return{result:this.parse(s),keyword:e}}searchByTag(t){t.startsWith(\"#\")&&(t=t.substring(1));let e=this.sqlite.query({sql:`SELECT * FROM tag WHERE tag like \"%${this.replaceString(t)}%\"`}),i=this.parseTag(e),s=[];return i.forEach(t=>{s.push(this.getByUUID(t.uuid))}),{result:s,keyword:[t]}}deleteTable(t){let e=this.sqlite.update(`DELETE FROM ${t}`);if(!e.result)throw e.error;this.needUpload(),this.kernel.logger.info(`delete table ${t}`)}all(t){let e=this.sqlite.query(`SELECT ${t}.*, tag, '${t}' AS section FROM ${t} LEFT JOIN tag ON ${t}.uuid = tag.uuid`);return this.parse(e)}saveImage(t){if(\"object\"==typeof t){let e=$text.uuid,s={original:`${this.imagePath.original}/${e}.png`,preview:`${this.imagePath.preview}/${e}.jpg`};return this.kernel.fileStorage.write(s.original,t.png),this.kernel.fileStorage.write(s.preview,i.compressImage(t).jpg(.8)),a.pathToKey(s)}throw Error(\"saveImageError: image not an object\")}insert(t){let e=this.sqlite.update({sql:`INSERT INTO ${t.section} (uuid, text, prev, next) values (?, ?, ?, ?)`,args:[t.uuid,t.text,t.prev,t.next]});if(!e.result)throw e.error;this.needUpload()}update(t){if(Object.keys(t).length<4||\"string\"!=typeof t.uuid)return;let e=this.sqlite.update({sql:`UPDATE ${t.section} SET text = ?, prev = ?, next = ? WHERE uuid = ?`,args:[t.text,t.prev,t.next,t.uuid]});if(!e.result)throw e.error;this.needUpload()}updateText(t,e,i){if(\"string\"!=typeof e)return;let s=this.sqlite.update({sql:`UPDATE ${t} SET text = ? WHERE uuid = ?`,args:[i,e]});if(!s.result)throw s.error;this.needUpload()}delete(t,e){this.getByUUID(e);let i=this.sqlite.update({sql:`DELETE FROM ${t} WHERE uuid = ?`,args:[e]});if(!i.result)throw i.error;this.needUpload()}isEmpty(){let t=this.sqlite.query(\"SELECT * FROM clips limit 1\").result,e=this.sqlite.query(\"SELECT * FROM favorite limit 1\").result;return t.next(),e.next(),t.isNull(0)&&e.isNull(0)}allImageFromDb(t=!0){let e=this.sqlite.query(`\n SELECT a.* from\n (SELECT *, 'clips' AS section FROM clips WHERE text like \"@image=%\"\n UNION\n SELECT *, 'favorite' AS section FROM favorite WHERE text like \"@image=%\") a\n LEFT JOIN tag ON a.uuid = tag.uuid\n `),i=this.parse(e)?.map(t=>{if(t.image){let e=t.fsPath;return e.preview=e.preview.replaceAll(this.imagePath.preview,\"\"),e.preview.startsWith(\"/\")&&(e.preview=e.preview.substring(1)),e.original=e.original.replaceAll(this.imagePath.original,\"\"),e.original.startsWith(\"/\")&&(e.original=e.original.substring(1)),e}}),s=[],n=[];return t||i.forEach(t=>{s.push(t.original),n.push(t.preview)}),t?i:{original:s,preview:n}}localImagesFromFile(){return{original:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.original),preview:this.kernel.fileStorage.readSync(this.kernel.storage.imagePath.preview)}}setTag(t,e){let i=this.sqlite.update({sql:\"INSERT OR REPLACE INTO tag (uuid, tag) values (?, ?)\",args:[t,e]});if(!i.result)throw i.error;this.needUpload()}deleteTag(t){let e=this.sqlite.update({sql:\"DELETE FROM tag WHERE uuid = ?\",args:[t]});if(!e.result)throw e.error;this.needUpload()}addDir(t){let e=this.sqlite.update({sql:\"INSERT INTO dir (uuid, name) values (?, ?)\",args:[$text.uuid,t]});if(!e.result)throw e.error;this.needUpload()}deleteDir(t){this.beginTransaction();let e=this.sqlite.update({sql:\"DELETE FROM dir WHERE uuid = ?\",args:[t]});if(!e.result)throw this.rollback(),e.error;let i=this.sqlite.update({sql:\"DELETE FROM dir_link WHERE dir_uuid = ?\",args:[t]});if(!i.result)throw this.rollback(),i.error;this.commit(),this.needUpload()}}t.exports={Clip:a,Storage:r}}),a(\"7GYtH\",function(t,e){var i=n(\"gxpqj\").FileStorage,s=n(\"2VUvw\");class a extends s{localSyncDataPath=\"/sync.json\";webdavSyncDataPath=\"/sync.json\";webdavDbPath=\"/CAIO.db\";webdavImagePath=\"/image\";get localDb(){return $data({path:this.kernel.fileStorage.filePath(this.kernel.storage.localDb)})}set localDb(t){this.kernel.fileStorage.writeSync(this.kernel.storage.localDb,t)}get localImagePath(){return this.kernel.fileStorage.filePath(\"/image\")}async init(){await super.init(),await this.initImagePath(),this.sync()}async initImagePath(){await this.webdav.exists(this.webdavImagePath)||(await this.webdav.mkdir(this.webdavImagePath),[\"/image/original\",\"/image/preview\"].map(async t=>{await this.webdav.exists(t)||await this.webdav.mkdir(t)}))}isNew(){return this.kernel.storage.isEmpty()}async webdavImages(){let t=(await this.webdav.ls(this.webdavImagePath,\"infinity\")).rootElement,e=t.firstChild({xPath:\"//D:response/D:href\"}).string,i=[],s=[];return t.children().map(t=>{let n=t.firstChild({tag:\"href\"})?.string?.replaceAll(e,\"\");!n.endsWith(\"/\")&&(n.startsWith(\"original\")?i.push(n.substring(9)):n.startsWith(\"preview\")&&s.push(n.substring(8)))}),{original:i,preview:s}}async syncImages(){let t=await this.webdavImages(),e=this.kernel.storage.allImageFromDb(!1),s=this.kernel.storage.localImagesFromFile();Object.keys(s).map(t=>{s[t].forEach(async s=>{if(!e[t].includes(s)){let e=i.join(this.kernel.storage.imagePath[t],s);this.kernel.fileStorage.delete(e),this.kernel.logger.info(`Local image deleted: ${e}`)}})}),Object.keys(e).map(s=>{e[s].forEach(async e=>{let n=i.join(this.webdavImagePath,s,e),a=i.join(this.kernel.storage.imagePath[s],e);if(t[s].includes(e)&&!this.kernel.fileStorage.exists(a)){let t=await this.webdav.get(n);this.kernel.fileStorage.writeSync(a,t.rawData),this.kernel.logger.info(`WebDAV image downloaded: ${a}`)}else if(!t[s].includes(e)){let t=this.kernel.fileStorage.readSync(a);await this.webdav.put(n,t),this.kernel.logger.info(`WebDAV image uploaded: ${n}`)}})}),Object.keys(t).map(s=>{t[s].forEach(async t=>{if(!e[s].includes(t)){let e=i.join(this.webdavImagePath,s,t);await this.webdav.delete(e),this.kernel.logger.info(`WebDAV image deleted: ${e}`)}})})}async pull(){this.webdav.clearNSURLCache();let t=await this.webdav.get(this.webdavDbPath);this.localDb=t.rawData,await this.downloadSyncData(),this.kernel.storage.init(),await this.syncImages(),this.kernel.logger.info(\"clip webdav sync: pulled\")}async push(){await this.webdav.put(this.webdavDbPath,this.localDb),await this.uploadSyncData(),await this.syncImages(),this.kernel.logger.info(\"clip webdav sync: pushed\")}notify(t){$app.notify({name:\"clipSyncStatus\",object:t})}async #u(){let t=!1;try{let e=await this.nextSyncStep();if(this.kernel.logger.info(`clip nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else if(e===s.step.conflict){if(await this.conflict($l10n(\"CLIPS\"))!==a.conflictKeep.webdav)return;t=!0}else{this.notify({status:s.status.nochange});return}this.notify({status:s.status.success,updateList:t})}catch(t){throw this.notify({status:s.status.fail,error:t}),this.kernel.logger.error(\"clip sync error\"),this.kernel.logger.error(t),t}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,()=>{this.#u()})}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,()=>{this.updateLocalTimestamp(),this.#u()})}}t.exports=a}),a(\"2VUvw\",function(t,e){var i=n(\"gxpqj\").WebDAV;class s{static step={init:-1,stay:0,needPush:2,needPull:3,conflict:4};static stepName=(()=>{let t={};return Object.keys(s.step).map(e=>{t[s.step[e]]=String(e)}),t})();static status={syncing:0,success:1,nochange:2,fail:3};static conflictKeep={local:0,webdav:1,cancel:2};static initLocalTimestamp=0;webdav;kernel;localSyncDataPath;webdavSyncDataPath;constructor({host:t,user:e,password:s,basepath:n,kernel:a}={}){this.kernel=a,this.webdav=new i({host:t,user:e,password:s,basepath:n}),this.webdav.namespace=\"JSBox.CAIO\"}get mustLocalSyncDataPath(){if(!this.localSyncDataPath)throw Error(\"localSyncDataPath not set\");return this.localSyncDataPath}get mustWebdavSyncDataPath(){if(!this.webdavSyncDataPath)throw Error(\"webdavSyncDataPath not set\");return this.webdavSyncDataPath}get localSyncData(){return this.kernel.fileStorage.exists(this.mustLocalSyncDataPath)||(this.localSyncData={timestamp:s.initLocalTimestamp}),this.kernel.fileStorage.readSync(this.mustLocalSyncDataPath)}set localSyncData(t){this.kernel.fileStorage.writeSync(this.mustLocalSyncDataPath,$data({string:JSON.stringify(t)}))}get localTimestamp(){return Number(JSON.parse(this.localSyncData.string).timestamp)}set localTimestamp(t){this.localSyncData=Object.assign(this.localSyncData,{timestamp:t})}async init(t=this.webdav.basepath){let e=new i({host:this.webdav.host,user:this.webdav.user,password:this.webdav.password,basepath:t});if(!await e.exists(\"/\"))try{await e.mkdir(\"/\")}catch(e){if(409===e.code){await this.init(t.substring(0,t.lastIndexOf(\"/\"))),await this.init(t);return}throw e}}isNew(){return!1}async webdavSyncData(){this.webdav.clearNSURLCache();let t=(await this.webdav.get(this.mustWebdavSyncDataPath)).data;return\"string\"==typeof t&&(t=JSON.parse(t)),t}async webdavTimestamp(){try{let t=await this.webdavSyncData();return Number(t.timestamp)}catch(t){if(404===t.code)return s.step.init;throw t}}updateLocalTimestamp(){this.localTimestamp!==s.initLocalTimestamp&&(this.localTimestamp=Date.now())}async uploadSyncData(){this.localTimestamp===s.initLocalTimestamp&&(this.localTimestamp=Date.now()),await this.webdav.put(this.mustWebdavSyncDataPath,this.localSyncData)}async downloadSyncData(){this.localSyncData=await this.webdavSyncData()}async nextSyncStep(){let t=this.localTimestamp,e=await this.webdavTimestamp();return e===s.step.init?s.step.init:e===s.initLocalTimestamp?(this.localTimestamp=Date.now(),await this.push(),s.step.stay):t>e?s.step.needPush:t===e?s.step.stay:t{$widget.reloadTimeline(),!this.needReload&&$(this.views.listId).ocValue().$isEditing()||(this.updateList(!0),$delay(.5,()=>{this.readClipboard()}))},clipSyncStatus:t=>{let e=$(this.views.listId);t.status===g.status.success||t.status===g.status.nochange?(t.updateList&&this.updateList(!0),e&&e.endRefreshing()):t.status===g.status.syncing&&t.animate&&e&&e.beginRefreshing()}})}setDelegate(){this.delegates.setEditingCallback(t=>{this.navigationView.navigationBarItems.getButtons().forEach(e=>{e.id===this.views.listId+\"-navbtn-edit\"?e.setTitle(t?$l10n(\"DONE\"):$l10n(\"EDIT\")):t?e.hide():e.show()})}),this.delegates.setDelegate()}async checkUrlScheme(){if($context.query.runAction){let t=JSON.parse($text.base64Decode($context.query.runAction));this.kernel.actions.getAction(t.category,t.dir,new m({env:f.widget})).do();return}if($context.query.copy){let t=$context.query.copy;this.setCopied(t),$ui.success($l10n(\"COPIED\"))}else $context.query.add?this.getAddTextView():$context.query.actions&&(this.kernel.isUseJsboxNav?this.kernel.actions.present():this.kernel.tabBarController.switchPageTo(\"actions\"))}listReady(){this.setDelegate(),this.updateList(),$delay(.5,()=>{this.readClipboard()}),a.isTaio||($delay(0,()=>this.checkUrlScheme()),this.appListen())}updateList(t=!1){t&&this.setNeedReload(),$(this.views.listId).data=this.clips.map(t=>this.views.lineData(t,this.copied.uuid===t.uuid)),this.updateListBackground()}updateListBackground(){this.clips.length>0?$(this.views.listId).ocValue().$setBackgroundView(void 0):$(this.views.listId).ocValue().$setBackgroundView($ui.create(this.views.getEmptyBackground(this.clips.length>0)))}updateCopied(t=null){let e=this.copied?.uuid;$delay(0,()=>{let i=$(this.views.listId),s=i.cell($indexPath(0,this.getIndexByUUID(e)));if(s&&(s.get(\"copied\").hidden=!0),t){let e=this.getIndexByUUID(t.uuid);i.cell($indexPath(0,e)).get(\"copied\").hidden=!1}}),t?Object.assign(this.copied,t):this.copied={},this.kernel.logger.info(`this.copied: ${JSON.stringify(this.copied,null,2)}`),$cache.set(\"clips.copied\",this.copied)}focusAnimation(t){$delay(.3,()=>{let e=$(this.views.listId),i=this.getIndexByUUID(t),s=0;for(let t=0;t0){t&&(await $wait(.1),$clipboard.images.forEach(t=>{this.add(t)}));return}let e=$clipboard.text;if(!e||\"\"===e){this.clearCopied();return}if(this.getClip(this.copied?.uuid)?.text===e){t&&$ui.toast($l10n(\"CLIPBOARD_NO_CHANGE\")),this.switchTab(this.tabItemsMap[this.copied.section],!0),this.focusAnimation(this.copied.uuid);return}if(this.exists(e)){let t=this.kernel.storage.getByText(e);this.switchTab(this.tabItemsMap[t.section],!0),this.setCopied(t.uuid)}else{this.switchTab(1,!0);let t=await this.add(e);this.setCopied(t.uuid)}}}async add(t,e=!0){try{let i=super.addItem(t);if(!e)return;return this.updateListBackground(),await $wait(.1),$(this.views.listId).insert({indexPath:$indexPath(0,0),value:this.views.lineData(i)}),i}catch(t){$ui.warning(t)}}delete(t){try{super.deleteItem(t),this.copied.uuid===t&&(this.updateCopied(),$clipboard.clear()),this.updateListBackground()}catch(t){$ui.alert(t)}}update(t,e){try{return super.updateItem(t,e),this.updateList(),e===this.copied.uuid&&this.setClipboardText(t),!0}catch(t){return $ui.alert(t),!1}}favorite(t){let e=this.getByIndex(t);if(e?.section===\"favorite\")return;let i=this.kernel.storage.getByUUID(e.uuid);if(i?.section===\"favorite\"){h.warning(\"Already exists\");return}try{super.favoriteItem(e.uuid),$(this.views.listId).delete(t)}catch(t){$ui.alert(t)}}copy(t){let e=this.getClip(t);if(e.image?$clipboard.image=e.imageOriginal:this.setCopied(t,!1),0!==this.tabIndex){let e=this.getIndexByUUID(t);try{super.moveItem(e,0);let t=$(this.views.listId).ocValue(),i=$indexPath(0,e).ocValue(),s=$indexPath(0,0).ocValue();t.$moveRowAtIndexPath_toIndexPath(i,s)}catch(t){$ui.alert(t)}}}getAddTextView(){this.views.edit(\"\",t=>{\"\"!==t&&this.add(t)})}switchTab(t,e=!1){this.tabIndex=t,this.updateList(),e&&($(this.views.listId+\"-tab\").index=this.tabIndex),this.delegates.setEditing(!1)}getTabView(){return this.views.tabView(this.tabItems,this.tabIndex,{changed:t=>this.switchTab(t.index)})}getListView(){return this.views.getListView(this.views.listId,[],{ready:()=>this.listReady(),pulled:t=>{this.updateList(!0),this.kernel.storage.sync(),this.kernel.setting.get(\"webdav.status\")||$delay(.5,()=>t.endRefreshing())}})}getNavigationView(){let t=new d(this.kernel);t.setCallback(e=>{let i=new r,s=(t=>{let{keyword:e,result:s,isTagKeyword:n}=t;return this.views.getListView(this.views.listId+\"-search-result\",s.map(t=>{let i=n?t.tag:t.text,s=[];return e.forEach(t=>{let e=i.indexOf(t);for(;e>-1;)s.push({range:$range(e,t.length),color:$color(\"red\")}),e=i.indexOf(t,e+1)}),t.styledText={},n?t.tagStyledText={color:this.views.tagColor,text:i,styles:s}:t.textStyledText={text:i,styles:s},this.views.lineData(t,!1)}),{ready:()=>this.updateList(),didSelect:(t,e)=>{let n=s[e.row];n.image?r.quickLookImage(n.imageOriginal):(i.dismiss(),this.views.edit(n.text,t=>{n.text!==t&&this.update(t,n.uuid)}))},rowHeight:(t,e)=>{let i=s[e.row],n=i?.hasTag?this.views.tagHeight:this.views.verticalMargin,a=i.image?this.views.imageContentHeight:this.views.getContentHeight(i.text);return this.views.verticalMargin+a+n}})})(e);s.props.bgcolor=a.primaryViewBackgroundColor,i.setView(s).addNavBar({title:$l10n(\"SEARCH_RESULT\"),popButton:{title:$l10n(\"DONE\"),tapped:()=>t.dismiss()}}).init().present()});let e=this.getTabView();e.type=\"menu\",e.layout=(t,e)=>{t.left.right.equalTo(e.super),t.height.equalTo(this.views.tabHeight),this.kernel.isUseJsboxNav&&a.isTaio?t.top.equalTo(e.super).offset(a.PageSheetNavigationBarNormalHeight):t.top.equalTo(e.super)};let i=s.createFromViews([e,this.getListView(),t.getSearchHistoryView()]);return this.navigationView=new o().navigationBarTitle($l10n(\"CLIPS\")).setView(i),this.navigationView.navigationBarItems.setTitleView(t.getSearchBarView()).pinTitleView().setRightButtons([{symbol:\"plus.circle\",tapped:()=>this.getAddTextView()}]).setLeftButtons([{id:this.views.listId+\"-navbtn-edit\",title:$l10n(\"EDIT\"),tapped:()=>this.delegates.setEditing()},{symbol:\"square.and.arrow.down.on.square\",tapped:async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){t.cancel(),this.kernel.logger.error(e)}}}]),this.navigationView.navigationBar.setBackgroundColor(a.primaryViewBackgroundColor).setLargeTitleDisplayMode(l.largeTitleDisplayModeNever),this.kernel.isUseJsboxNav&&this.navigationView.navigationBar.removeTopSafeArea(),this.navigationView}}t.exports=w}),a(\"ZnuTV\",function(t,e){var i=n(\"gxpqj\").UIKit,s=n(\"jEwwi\").Clip;class a{kernel;pasteboard=$objc(\"UIPasteboard\").$generalPasteboard();#p=[];clipsUUIDMap={};rememberTabIndex=!0;#g=0;tabItems=[$l10n(\"FAVORITE\"),$l10n(\"CLIPS\")];tabItemsIndex=[\"favorite\",\"clips\"];tabItemsMap=(function(t){let e={};return t.forEach((t,i)=>{e[t]=i}),e})(this.tabItemsIndex);constructor(t){this.kernel=t}get tabIndex(){return this.rememberTabIndex?$cache.get(\"caio.main.tab.index\")??0:this.#g}set tabIndex(t){this.rememberTabIndex?$cache.set(\"caio.main.tab.index\",t):this.#g=t}get table(){return this.tabItemsIndex[this.tabIndex]}get tableL10n(){return this.tabItems[this.tabIndex]}get allClips(){return this.tabItemsIndex.forEach((t,e)=>{this.#p[e]||(this.#p[e]=this.#y(t),this.kernel.logger.info(`init clips: ${t}`))}),this.#p}get clips(){return this.#p[this.tabIndex]||(this.#p[this.tabIndex]=this.#y(this.table),this.kernel.logger.info(`init clips: ${this.table}`)),this.#p[this.tabIndex]}get isPasteboardChanged(){let t=this.pasteboard.$changeCount();return $cache.get(\"clipboard.changeCount\")!==t&&($cache.set(\"clipboard.changeCount\",t),!0)}get needReload(){return $cache.get(\"caio.needReload\")??!1}set needReload(t){$cache.get(\"caio.needReload\",t)}#y(t){try{let e=this.kernel.storage.all(t),i=this.kernel.storage.sort(e,this.kernel.setting.get(\"clipboard.maxItemLength\"));return i.forEach((e,i)=>{this.clipsUUIDMap[e.uuid]={tab:t,index:i}}),this.#f(i)}catch(t){this.kernel.logger.error(t),this.rebuildDatabase()}}#f(t){return new Proxy(t??[],{set:(t,e,i)=>Reflect.set(t,e,i),get:(t,e)=>Reflect.get(t,e)})}rebuildDatabase(){$ui.alert({title:$l10n(\"REBUILD_DATABASE\"),message:$l10n(\"CLIPS_STRUCTURE_ERROR\"),actions:[{title:$l10n(\"OK\"),handler:()=>{let t=i.loading();t.start(),this.kernel.storage.rebuild(),t.end(),$delay(.8,()=>$addin.restart())}},{title:$l10n(\"CANCEL\")}]})}setNeedReload(t){t?this.#p[this.tabItemsMap[t]]=null:this.#p=[],this.needReload=!0,this.kernel.logger.info(`set need reload: ${t??\"all\"}`)}getClipCopy(t,e={}){if(!t.uuid)return t;let i=new s(t);return i.fileStorage=t.fileStorage,Object.assign(i,e),i}getIndexByUUID(t){return this.clipsUUIDMap[t]?.index??-1}getClip(t){return this.clips[this.getIndexByUUID(t)]||this.kernel.storage.getByUUID(t)}exists(t){try{let e=this.kernel.storage.getByText(t);return void 0!==e}catch{return!1}}setClipboardText(t){this.kernel.setting.get(\"clipboard.universal\")?$clipboard.text=t:$clipboard.setTextLocalOnly(t)}addItem(t){if(this.exists(t))throw Error(\"Item already exists\");let e=new s({uuid:$text.uuid,section:this.table,prev:null,next:this.clips[0]?this.clips[0].uuid:null});if(\"string\"==typeof t){if(\"\"===t.trim())return;e.text=t}else{if(\"object\"!=typeof t)return;e.fileStorage=this.kernel.fileStorage,e.text=this.kernel.storage.saveImage(t)}try{return this.kernel.storage.beginTransaction(),this.kernel.storage.insert(e),e.next&&(this.clips[0].prev=e.uuid,this.kernel.storage.update(this.clips[0])),this.kernel.storage.commit(),this.setNeedReload(this.table),e}catch(t){throw this.kernel.storage.rollback(),this.kernel.logger.error(t),t}}getRecycleBin(){return $cache.get(\"caio.recycleBin\")??[]}moveToRecycleBin(t){let e=this.getRecycleBin();e.push({text:t.text,tag:t.tag}),$cache.set(\"caio.recycleBin\",e)}removeFromRecycleBin(t){let e=this.getRecycleBin();e.splice(t,1),$cache.set(\"caio.recycleBin\",e)}clearRecycleBin(){$cache.set(\"caio.recycleBin\",[])}deleteItem(t,e=!0){let i=this.getIndexByUUID(t),s=this.clips[i],n=this.clips[i-1],a=this.clips[i+1];try{this.kernel.storage.beginTransaction(),this.kernel.storage.delete(this.table,t),n&&(n.next=s.next,this.kernel.storage.update(n)),a&&(a.prev=s.prev,this.kernel.storage.update(a)),this.kernel.storage.commit(),e&&(this.kernel.storage.deleteTag(t),s?.image?(this.kernel.fileStorage.delete(s.fsPath.original),this.kernel.fileStorage.delete(s.fsPath.preview)):this.moveToRecycleBin(s)),this.setNeedReload(this.table)}catch(t){throw this.kernel.storage.rollback(),this.kernel.logger.error(t),t}}updateItem(t,e){let i=this.getClip(e),s=i.text;Object.assign(i,{text:t});try{this.kernel.storage.updateText(this.table,i.uuid,t),this.kernel.logger.info(`data changed at index [${this.getIndexByUUID(e)}]\n${s}\n\\u{2193}\n${t}`)}catch(t){throw this.kernel.logger.error(t),t}}moveItem(t,e){if(t!==e&&1!==this.clips.length){t{};onBegin=()=>{};onDismiss=()=>{};constructor(t){this.kernel=t,this.searchBar=new a,this.searchBarId=this.searchBar.id+\"-input\"}get searchHistoryView(){return{hide:()=>$(this.listId+\"-history\").hidden=!0,show:()=>$(this.listId+\"-history\").hidden=!1}}get searchHistory(){return[{title:$l10n(\"SEARCH_HISTORY\"),rows:$cache.get(\"caio.search.history\")?.reverse()??[]}]}getAccessoryView(){return s.blurBox({height:50},[{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"xmark.circle\"},layout:(t,e)=>{t.right.inset(0),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>this.dismiss()}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:$color(\"primaryText\"),symbol:\"keyboard.chevron.compact.down\"},layout:(t,e)=>{t.right.equalTo(e.prev.left),t.height.equalTo(e.super),t.width.equalTo(e.super.height)},events:{tapped:()=>$(this.searchBarId).blur()}}])}getSearchHistoryView(){return{type:\"list\",props:{id:this.listId+\"-history\",hidden:!0,stickyHeader:!0,data:this.searchHistory,separatorInset:$insets(0,13,0,0),actions:[{title:$l10n(\"DELETE\"),handler:(t,e)=>{let i=t.data;this.updateSearchHistory(i[0].rows.reverse())}}]},events:{didSelect:(t,e,i)=>{this.searchAction(i),$(this.searchBarId).text=i}},layout:$layout.fill}}setCallback(t){this.callback=t}setOnBegin(t){this.onBegin=t}setOnDismiss(t){this.onDismiss=t}begin(){this.searchHistoryView.show(),this.onBegin()}dismiss(){this.searchBar.cancel()}async searchAction(t){try{if(\"\"!==t){let e=t.startsWith(\"#\"),{result:i,keyword:s}=e?this.kernel.storage.searchByTag(t.substring(1)):await this.kernel.storage.search(t);i&&i.length>0?($(this.searchBarId).blur(),this.callback({keyword:s,result:i,isTagKeyword:e})):$ui.toast($l10n(\"NO_SEARCH_RESULT\")),this.pushSearchHistory(t)}}catch(t){throw t}}pushSearchHistory(t){let e=$cache.get(\"caio.search.history\")??[];-1===e.indexOf(t)&&(e.push(t),e.length>20&&(e=e.slice(-20)),$cache.set(\"caio.search.history\",e),$(this.listId+\"-history\").data=this.searchHistory)}updateSearchHistory(t=[]){$cache.set(\"caio.search.history\",t)}getSearchBarView(){return this.searchBar.controller.setEvent(\"onReturn\",t=>{\"\"!==t?this.searchAction(t):this.searchHistoryView.show()}),this.searchBar.controller.setEvent(\"onChange\",t=>{\"\"===t&&this.searchHistoryView.show()}),this.searchBar.controller.setEvent(\"onBeginEditing\",t=>{\"\"===t&&this.begin()}),this.searchBar.controller.setEvent(\"onCancel\",()=>{this.searchHistoryView.hide(),this.onDismiss()}),this.searchBar.setAccessoryView(this.getAccessoryView()),this.searchBar}}t.exports=r}),a(\"iGysH\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.ViewController,r=n(\"f0nX9\");class o{listId=$text.uuid;editingToolBarId=this.listId+\"-edit-mode-tool-bar\";#m=!1;#w=0;scrollToOffsetDirectionX=!1;tabLeftMargin=20;horizontalMargin=20;verticalMargin=14;containerMargin=0;fontSize=16;copiedIndicatorSize=6;imageContentHeight=50;tagHeight=this.verticalMargin+5;tagColor=$color(\"lightGray\");tabHeight=44;editModeToolBarHeight=44;#$={};viewController;constructor(t){this.kernel=t,this.viewController=new a}get singleLineContentHeight(){return 0===this.#w&&(this.#w=this.getTextHeight($font(this.fontSize))),this.#w}setSingleLine(){this.#m=!0,this.imageContentHeight=this.singleLineContentHeight,this.#w=0}getTextHeight(t,e=\"a\"){return $text.sizeThatFits({text:e,font:t,width:s.windowSize.width-(this.horizontalMargin+this.containerMargin)*2}).height}getContentHeight(t){return this.#$[t]||(this.#$[t]=this.#m?this.singleLineContentHeight:Math.min(this.getTextHeight($font(this.fontSize),t),2*this.singleLineContentHeight)),this.#$[t]}edit(t,e){let i=new r(this.kernel),s=[{symbol:\"square.and.arrow.up\",tapped:()=>{i.text?$share.sheet(i.text):$ui.warning($l10n(\"NONE\"))}}];if(this.kernel.isUseJsboxNav)i.uikitPush(t,t=>e(t),s);else{let n=i.getNavigationView(t,t=>e(t),s);this.viewController.push(n)}}tabView(t,e,i){return{type:\"tab\",props:{id:this.listId+\"-tab\",items:t,index:e,dynamicWidth:!0},events:i,layout:(t,e)=>{t.centerY.equalTo(e.super),e.prev?t.left.equalTo(e.prev.right).offset(this.tabLeftMargin):t.left.inset(this.tabLeftMargin)}}}lineData(t,e=!1){let i={hidden:!0},s={text:\"\"},n={hidden:!t?.hasTag};return t.image?(i.data=t.imagePreview,i.hidden=!1):(t.textStyledText?s.styledText=t.textStyledText:s.text=t.text,t.tagStyledText?n.styledText=t.tagStyledText:n.text=t.tag),{copied:{hidden:!e},image:i,tag:n,content:s}}listTemplate(){return{props:{bgcolor:$color(\"clear\")},views:[{type:\"view\",views:[{type:\"view\",props:{id:\"copied\",circular:this.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.size.equalTo(this.copiedIndicatorSize),t.left.equalTo(e.super).inset(this.horizontalMargin/2-this.copiedIndicatorSize/2)}},{type:\"label\",props:{id:\"content\",lines:this.#m?1:2,font:$font(this.fontSize)},layout:(t,e)=>{t.left.right.equalTo(e.super).inset(this.horizontalMargin),t.top.equalTo(this.verticalMargin)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.bottom.equalTo(e.super),t.left.right.equalTo(e.prev),t.height.equalTo(this.tagHeight)}}],layout:$layout.fill},{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}getEmptyBackground(t=!1){return{type:\"label\",props:{color:$color(\"secondaryText\"),hidden:t,text:$l10n(\"NONE\"),align:$align.center},events:{ready:t=>{t.layout((t,e)=>{t.top.equalTo(this.tabHeight),t.left.right.bottom.equalTo(e.super)})}}}}getListEditModeToolBarView({selectButtonEvents:t,deleteButtonEvents:e}={}){return s.blurBox({id:this.editingToolBarId},[s.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.editingToolBarId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.inset(this.horizontalMargin),t.centerY.equalTo(e.super)},events:t},{type:\"button\",props:{id:this.editingToolBarId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(2*this.horizontalMargin),t.right.inset(this.horizontalMargin/2),t.centerY.equalTo(e.super)},events:e}],layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom)}}])}getListView(t=this.listId,e=[],i){return{type:\"list\",props:{id:t,associateWithNavigationBar:!1,bgcolor:$color(\"clear\"),separatorInset:$insets(0,this.horizontalMargin,0,0),data:e,allowsMultipleSelectionDuringEditing:!0,template:this.listTemplate(),backgroundView:$ui.create(this.getEmptyBackground())},events:i,layout:(t,e)=>{e.prev?t.top.equalTo(e.prev.bottom):t.top.equalTo(e.super),t.left.right.bottom.equalTo(e.super)}}}}t.exports=o}),a(\"f0nX9\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.NavigationBar,r=i.NavigationView,o=i.Sheet,l=n(\"eSp9Z\"),h=l.ActionEnv,c=l.ActionData;t.exports=class{#h=\"\";originalContent;constructor(t){this.kernel=t,this.id=\"editor\"}set text(t=\"\"){void 0===this.originalContent&&(this.originalContent=t),this.#h=t}get text(){return this.#h}getActionButton(){return{symbol:\"bolt.circle\",tapped:(t,e)=>{e&&(t=e);let i=$(this.id).selectedRange,s=new c({env:h.editor,editor:{originalContent:this.originalContent,setContent:t=>this.setContent(t)},text:i.length>0?this.text.slice(i.location,i.location+i.length):this.text,allText:this.text,selectedText:this.text.slice(i.location,i.location+i.length),selectedRange:i}),n=$ui.popover({sourceView:t,directions:$popoverDirection.up,size:$size(200,300),views:[this.kernel.actions.views.getActionListView(t=>{n.dismiss(),$delay(.5,()=>t(s))})]})}}}setContent(t){this.text=t,$(this.id).text=t}getView(t=\"text\"){return{type:t,layout:$layout.fill,props:{id:this.id,lineNumbers:this.kernel.setting.get(\"editor.code.lineNumbers\"),theme:this.kernel.setting.get($device.isDarkMode?\"editor.code.darkTheme\":\"editor.code.lightTheme\"),text:this.text,insets:$insets(15,15,\"text\"===t?this.kernel.setting.get(\"editor.text.insets\"):15,15)},events:{ready:t=>{\"\"===this.text&&$delay(.5,()=>t.focus())},didChange:t=>{this.text=t.text}}}}pageSheet(t=\"\",e,i,s=[],n=\"text\"){this.text=t,s.unshift(this.getActionButton());let a=new o;a.setView(this.getView(n)).addNavBar({title:i,popButton:{title:$l10n(\"DONE\"),tapped:()=>e(this.text)},rightButtons:s}).init(),a.navigationView.navigationBar.contentViewHeightOffset=0,a.present()}getViewController(t,e){return $define({type:\"EditorViewController: UIViewController\",events:{viewDidLoad:()=>{self.$super().$viewDidLoad(),self.$view().jsValue().add(this.getView(t)),self.$navigationItem().$setLargeTitleDisplayMode(2)},\"viewDidDisappear:\":t=>{e()}}}),$objc(\"EditorViewController\").$new()}uikitPush(t=\"\",e,i=[],n=\"text\"){this.text=t,i.unshift(this.getActionButton()),s.push({title:\"\",navButtons:i.map(t=>(t.handler=t.tapped,t.tapped=void 0,t)),views:[this.getView(n)],disappeared:()=>e(this.text)})}getNavigationView(t=\"\",e,i=[],s=\"text\"){this.text=t,i.unshift(this.getActionButton());let n=new r;return n.navigationBar.contentViewHeightOffset=0,n.navigationBar.setLargeTitleDisplayMode(a.largeTitleDisplayModeNever),n.navigationBarItems.setRightButtons(i),n.setView(this.getView(s)).navigationBarTitle(\"\"),n.setEvent(\"onPop\",()=>e(this.text)),n}}}),a(\"eSp9Z\",function(t,e){var i=n(\"gxpqj\"),s=i.L10n,a=i.Sheet,r=n(\"jVlss\").SecureFunction;class o{static build=-1;static today=0;static editor=1;static clipboard=2;static action=3;static keyboard=4;static recursion=5;static widget=6}class l{env;args;text;allText;section;uuid;selectedRange;selectedText;textBeforeInput;textAfterInput;editor;constructor({env:t,args:e,text:i,allText:s=null,section:n=null,uuid:a=null,selectedRange:r=null,selectedText:o=null,textBeforeInput:l=null,textAfterInput:h=null,editor:c=null}={}){this.env=t,this.args=e,this.text=i,this.allText=s??i,this.section=n,this.uuid=a,this.selectedRange=r,this.selectedText=o,this.textBeforeInput=l,this.textAfterInput=h,this.editor=c}}t.exports={ActionEnv:o,ActionData:l,Action:class{#b;secureFunction;constructor(t,e,i){this.#b=t,this.config=e,this.secureFunction=new r(this.#b,this.config),i.env===o.build&&((i=this.preview()).env=o.build),Object.assign(this,i),this.originalContent=String(this.text);let n=this.l10n();Object.keys(n).forEach(t=>{s.add(t,n[t])})}preview(){return new l({env:o.build})}l10n(){return{}}pageSheet({view:t,title:e=\"\",done:i,doneText:s=$l10n(\"DONE\"),rightButtons:n=[]}){new a().setView(t).addNavBar({title:e,popButton:{title:s,tapped:()=>{i&&i()}},rightButtons:n}).init().present()}quickLookImage(t){a.quickLookImage(t)}getAllClips(){return{favorite:this.#b.storage.all(\"favorite\").map(t=>t.text),clips:this.#b.storage.all(\"clips\").map(t=>t.text)}}async clearAllClips(){if(0!==(await $ui.alert({title:$l10n(\"DELETE_DATA\"),message:$l10n(\"DELETE_TABLE\").replaceAll(\"${table}\",$l10n(\"CLIPS\")),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index)return!1;try{return this.#b.storage.deleteTable(\"clips\"),!0}catch(t){throw this.#b.logger.error(t),t}}setContent(t){this.text=t,this.env===o.editor?this.editor.setContent(t):this.env===o.clipboard&&(this.#b.storage.updateText(this.section,this.uuid,t),this.#b.clips.updateList(!0))}getAction(t,e,i){let s=this.#b.actions.getActionDirByName(e);return this.#b.actions.getAction(t,s,i)}async runAction(t,e){let i=this.getAction(t,e,new l({env:o.recursion}));return await i.do()}async request(t,e,i,s){return this.secureFunction.http.request({url:t,method:e,body:i,header:s,timeout:3})}getUrls(){let t=this.text??\"\";return[...new Set([...t.match(/https?:\\/\\/[\\w-]+(\\.[\\w-]+)*([\\p{Script=Han}\\w.,@?^=%&:/~+#()\\-]*[\\w@?^=%&/~+#()\\-])?/giu)||[],...t.match(/\\b\\w+:\\/\\/[\\w-]+(\\.[\\w-]+)*([\\p{Script=Han}\\w.,@?^=%&:/~+#()\\-]*[\\w@?^=%&/~+#()\\-])?/giu)||[]])]}addinRun(t){$addin.run(t)}}}}),a(\"jVlss\",function(t,e){class i{#b;#v;notAllowed='\"The parameter or method is not allowed in Action.\"';constructor(t,e){if(this.#b=t,this.#v=JSON.parse(JSON.stringify(e)),!this.#v?.name||this.#v?.name===\"undefined\")throw Error(\"Cannot get Action name.\")}get name(){return this.#v.name}set name(t){let e=$l10n(\"ACTION_RESET_NAME_WARNING\").replaceAll(\"${name}\",this.name).replaceAll(\"${to_name}\",t);throw $ui.alert({title:$l10n(\"ACTION_SAFETY_WARNING\"),message:e}),Error(e)}info(t){this.#b.logger.info(t)}error(t){this.#b.logger.error(t)}}class s extends i{rootPath=this.notAllowed;extensions=this.notAllowed;read(){throw Error(this.notAllowed)}async download(){throw Error(this.notAllowed)}write(){throw Error(this.notAllowed)}delete(){throw Error(this.notAllowed)}list(){throw Error(this.notAllowed)}copy(){throw Error(this.notAllowed)}move(){throw Error(this.notAllowed)}mkdir(){throw Error(this.notAllowed)}exists(){throw Error(this.notAllowed)}isDirectory(){throw Error(this.notAllowed)}merge(){throw Error(this.notAllowed)}absolutePath(){throw Error(this.notAllowed)}}class n extends i{#T=\"ActionHttpPermission\";get #A(){return $cache.get(this.#T)||(this.#A={},{})}set #A(t={}){return $cache.set(this.#T,t)}async #E(){if(0===(await $ui.alert({title:$l10n(\"ACTION_PERMISSION_REQUEST\"),message:$l10n(\"ACTION_NETWORK_PERMISSION_MESSAGE\").replaceAll(\"${name}\",this.name),actions:[{title:$l10n(\"OK\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]})).index){let t=this.#A;return t[this.name]=!0,this.#A=t,!0}return!1}async #S(){let t=this.#A;return\"boolean\"==typeof t[this.name]?t[this.name]:!!await this.#E()}async request(t={}){try{if(!await this.#S())throw Error(\"No network permission.\");this.info(`sending request [${t.method}]: ${t.url}`);let e=await $http.request(Object.assign({timeout:3},t));if(\"function\"==typeof t?.handler&&t?.handler(e),e.error)throw e.error;if(e?.response?.statusCode>=400){let t=e.data;throw\"object\"==typeof t&&(t=JSON.stringify(t)),Error(\"Http error: [\"+e.response.statusCode+\"] \"+t)}return e}catch(t){throw t.code&&(t=Error(\"Network error: [\"+t.code+\"] \"+t.localizedDescription)),this.error(`Action request error: ${this.name}`),this.error(t),t}}async get(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"GET\",await this.request(t)}async post(t){return\"string\"==typeof t&&(t={url:t}),t.method=\"POST\",await this.request(t)}async download(){throw Error(this.notAllowed)}async upload(){throw Error(this.notAllowed)}async startServer(){throw Error(this.notAllowed)}async stopServer(){throw Error(this.notAllowed)}async shorten(t){return await $http.shorten(t)}async lengthen(t){return await $http.lengthen(t)}}t.exports={SecureFunction:class extends i{constructor(...t){super(...t),this.file=new s(...t),this.http=new n(...t)}addin(){throw Error(this.notAllowed)}},SecureScript:class{script;sf=\"this.secureFunction\";constructor(t){this.script=t}#I(t,e){this.script=this.script.replaceAll(t,e)}replaceEval(){this.#I(/\\$addin\\.*[a-zA-Z0-9\\[\\]'\"`]+/gi,`${this.sf}.addin()`),this.#I(\"eval\",`${this.sf}.addin()`)}replaceFile(){this.#I(\"$file\",`${this.sf}.file`)}replaceHttp(){this.#I(\"$http\",`${this.sf}.http`)}secure(){return this.replaceEval(),this.replaceFile(),this.replaceHttp(),this.script}}}}),a(\"a4uPv\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.Sheet,r=n(\"eSp9Z\"),o=r.ActionData,l=r.ActionEnv;t.exports=class{#x;menuItemActionMaxCount=5;placeholderReuseIdentifier=\"UITableViewPlaceholderReuseIdentifier\";constructor(t,e,i){this.kernel=t,this.data=e,this.views=i}initReuseIdentifier(t){if(!t.$dequeueReusableCellWithIdentifier(this.placeholderReuseIdentifier)){let e=$objc(\"UITableViewCell\").$class();t.$registerClass_forCellReuseIdentifier(e,this.placeholderReuseIdentifier)}}get listSelected(){let t=$(this.views.listId)?.ocValue()?.$indexPathsForSelectedRows()?.jsValue();return Array.isArray(t)?t:[]}get defaultMenuItems(){return[{inline:!0,items:[{title:$l10n(\"TAG\"),symbol:\"tag\",handler:(t,e)=>{let i=this.data.getByIndex(e);$input.text({placeholder:$l10n(\"ADD_TAG\"),text:i.tag,handler:t=>{(t=t.trim()).length>0?this.kernel.storage.setTag(i.uuid,t):this.kernel.storage.deleteTag(i.uuid),this.data.updateList(!0)}})}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(t,e)=>{let i=this.data.getByIndex(e);$share.sheet(i.image?i.imageOriginal:i.text)}},{title:$l10n(\"COPY\"),symbol:\"square.on.square\",handler:(t,e)=>this.data.copy(this.data.getByIndex(e).uuid)},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,items:[{title:$l10n(\"CONFIRM\"),destructive:!0,handler:(t,e)=>{t.delete(e),this.data.delete(this.data.getByIndex(e).uuid),$delay(.25,()=>t.reload())}}]}]}]}get menu(){let t=t=>{let e=this.kernel.actions.getActionHandler(t.category,t.dir);return t.handler=(t,i)=>{let s=this.data.getByIndex(i);e(new o({env:l.clipboard,text:s.text,section:s.section,uuid:s.uuid}))},t.title=t.name,t.symbol=t.icon,t},e=this.kernel.actions.getActions(\"clipboard\"),i={inline:!0,items:e.slice(0,this.menuItemActionMaxCount).map(t)};return e.length>this.menuItemActionMaxCount&&i.items.push({title:$l10n(\"MORE_ACTIONS\"),symbol:\"square.grid.2x2\",items:e.slice(this.menuItemActionMaxCount).map(t)}),{items:[i,...this.defaultMenuItems]}}setEditingCallback(t){this.#x=t}createUIMenu=({title:t,image:e,actions:i,inline:s=!1,destructive:n=!1}={})=>{let a;return s&&(a|=1),n&&(a|=2),$objc(\"UIMenu\").$menuWithTitle_image_identifier_options_children(t??\"\",e,null,a??0,i)};createUIAction=({title:t,image:e,handler:i,destructive:s=!1}={})=>{let n=$objc(\"UIAction\").$actionWithTitle_image_identifier_handler(t,e,null,$block(\"void, UIAction *\",t=>{i(t)}));return s&&n.$setAttributes(2),n};createUIContextualAction=({title:t,handler:e,color:i,image:s,destructive:n=!1}={})=>{let a=$objc(\"UIContextualAction\").$contextualActionWithStyle_title_handler(n?1:0,t,$block(\"void, UIContextualAction *, UIView *, block\",async(t,i,s)=>{s=t=>{t&&$(this.views.listId).ocValue().$setEditing_animated(!1,!0)},await e(t,i,s)}));return i&&a.$setBackgroundColor(i),s&&a.$setImage(s),a};createUITableViewDropPlaceholder(t){let e=$objc(\"UITableViewDropPlaceholder\").$alloc(),i=2*this.views.verticalMargin+this.views.getContentHeight(\"A\");return e.$initWithInsertionIndexPath_reuseIdentifier_rowHeight(t,this.placeholderReuseIdentifier,i),e}updateEditingToolBar(){let t=0===this.listSelected.length,e=$(this.views.editingToolBarId+\"-select-button\"),i=$(this.views.editingToolBarId+\"-delete-button\");e.title=t?$l10n(\"SELECT_ALL\"):$l10n(\"DESELECT_ALL\"),i.hidden=t}toggleAllSelected(t=!1,e=!0){let i=this.data.clips.length,s=$(this.views.listId).ocValue();if(t||0!==this.listSelected.length)for(let t=0;t{let t=this.listSelected.sort((t,e)=>t.rowthis.data.getByIndex(t).uuid);this.setEditing(!1),e.forEach(t=>this.data.delete(t)),t.forEach(t=>{$(this.views.listId).delete(t)})})}setEditing(t){let e=$(this.views.listId).ocValue(),i=void 0!==t?t:!e.$isEditing();if(i!==e.$isEditing()){if(e.$setEditing(i),\"function\"==typeof this.#x&&this.#x(i),i){let t=$ui.create(this.views.getListEditModeToolBarView({selectButtonEvents:{tapped:()=>this.toggleAllSelected()},deleteButtonEvents:{tapped:()=>this.deleteSelected()}}));$ui.window.add(t),$(this.views.editingToolBarId).layout((t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.views.editModeToolBarHeight)})}else $(this.views.editingToolBarId).remove()}}shouldBeginMultipleSelectionInteractionAtIndexPath(){return this.setEditing(!0),!0}didSelectRowAtIndexPath(t,e){if(t.$isEditing()){this.updateEditingToolBar();return}if(t.$hasActiveDrag())return;let i=this.data.getByIndex(e.jsValue());i.image?(a.quickLookImage(i.imageOriginal),t.$deselectRowAtIndexPath_animated(e,!0)):this.views.edit(i.text,s=>{t.$deselectRowAtIndexPath_animated(e,!0),i.text!==s&&this.data.update(s,i.uuid)})}didDeselectRowAtIndexPath(t,e){t.$isEditing()&&this.updateEditingToolBar()}contextMenuConfigurationForRowAtIndexPath(t,e,i){if(t.$isEditing())return;let s=i=>{let n=[];return i.items.forEach(i=>{i.items?n.push(s(i)):n.push(this.createUIAction({title:i.title,image:i.symbol,handler:()=>{i.handler(t.jsValue(),e.jsValue())},destructive:i.destructive}))}),this.createUIMenu({title:i.title,image:i.symbol,actions:n,inline:i.inline,destructive:i.destructive})};return $objc(\"UIContextMenuConfiguration\").$configurationWithIdentifier_previewProvider_actionProvider(null,null,$block(\"UIMenu *, NSArray *\",()=>s(this.menu)))}leadingSwipeActionsConfigurationForRowAtIndexPath(t,e){return $objc(\"UISwipeActionsConfiguration\").$configurationWithActions([this.createUIContextualAction({title:$l10n(\"COPY\"),color:$color(\"systemLink\"),handler:async(t,i,s)=>{this.data.copy(this.data.getByIndex(e.jsValue()).uuid),s(!0)}})])}trailingSwipeActionsConfigurationForRowAtIndexPath(t,e){t=t.jsValue(),e=e.jsValue();let i=[this.createUIContextualAction({destructive:!0,title:$l10n(\"DELETE\"),handler:(i,s,n)=>{this.data.delete(this.data.getByIndex(e).uuid),t.delete(e),$delay(.25,()=>t.reload())}})];return 1===this.data.tabIndex&&i.push(this.createUIContextualAction({title:$l10n(\"FAVORITE\"),color:$color(\"orange\"),handler:(t,i,s)=>{this.data.favorite(e.row)}})),$objc(\"UISwipeActionsConfiguration\").$configurationWithActions(i)}heightForRowAtIndexPath(t,e){t=t.jsValue(),e=e.jsValue();let i=this.data.getByIndex(e),s=i?.hasTag?this.views.tagHeight:this.views.verticalMargin,n=i?.image?this.views.imageContentHeight:this.views.getContentHeight(i?.text??\"a\");return this.data.itemSize[e.row]=this.views.verticalMargin+n+s,this.data.itemSize[e.row]}delegate(){return $delegate({type:\"UITableViewDelegate\",events:{\"tableView:shouldBeginMultipleSelectionInteractionAtIndexPath:\":()=>this.shouldBeginMultipleSelectionInteractionAtIndexPath(),\"tableView:didBeginMultipleSelectionInteractionAtIndexPath:\":(t,e)=>{this.setEditing(!0)},\"tableView:didSelectRowAtIndexPath:\":(t,e)=>{this.didSelectRowAtIndexPath(t,e)},\"tableView:didDeselectRowAtIndexPath:\":(t,e)=>{this.didDeselectRowAtIndexPath(t,e)},\"tableView:contextMenuConfigurationForRowAtIndexPath:point:\":(t,e,i)=>this.contextMenuConfigurationForRowAtIndexPath(t,e,i),\"tableView:leadingSwipeActionsConfigurationForRowAtIndexPath:\":(t,e)=>this.leadingSwipeActionsConfigurationForRowAtIndexPath(t,e),\"tableView:trailingSwipeActionsConfigurationForRowAtIndexPath:\":(t,e)=>this.trailingSwipeActionsConfigurationForRowAtIndexPath(t,e),\"tableView:heightForRowAtIndexPath:\":(t,e)=>this.heightForRowAtIndexPath(t,e)}})}itemsForBeginningDragSession(t,e){let i=this.data.getByIndex(e.jsValue()),s=$objc(\"NSItemProvider\").$alloc();if(i.image){let t=$file.absolutePath(i.imagePath.original),e=NSURL.$fileURLWithPath(t);s.$initWithContentsOfURL(e)}else s.$initWithObject(i.text);let n=$objc(\"UIDragItem\").$alloc().$initWithItemProvider(s),a=t.$localContext();if(a)a.$addObject(n);else{let e=NSMutableArray.$new();e.$addObject(n),t.$setLocalContext(e)}return[n]}dragDelegate(){return $delegate({type:\"UITableViewDragDelegate\",events:{\"tableView:itemsForBeginningDragSession:atIndexPath:\":(t,e,i)=>this.itemsForBeginningDragSession(e,i)}})}reorder(t){let e=t.$items().$firstObject(),i=e.$sourceIndexPath().jsValue().row,s=t.$destinationIndexPath(),n=s.jsValue().row;this.data.moveItem(i,n),this.data.updateList(),t.$dropItem_toRowAtIndexPath(e.$dragItem(),s)}dropItems(t){let e=t.$destinationIndexPath();e||(e=$indexPath(0,0));let i=t.$items(),s=i.$count();for(let n=0;n{e&&($ui.alert(e.jsValue()),this.kernel.logger.error(e.jsValue()));try{h?this.data.addItem(t.jsValue().string,!1):c&&this.data.addItem(t.jsValue().image,!1),r.$commitInsertionWithDataSourceUpdates($block(\"void, NSIndexPath *\",t=>{this.data.moveItem(0,t.jsValue().row),this.data.updateList()}))}catch(t){return r.$deletePlaceholder(),$ui.warning(t),!1}};o.$loadDataRepresentationForTypeIdentifier_completionHandler(l[0],$block(\"void, NSData *, NSError *\",(t,e)=>{$delay(0,()=>d(t,e))}))}}dropDelegate(){return $delegate({type:\"UITableViewDropDelegate\",events:{\"tableView:canHandleDropSession:\":(t,e)=>!t.$isEditing(),\"tableView:dropSessionDidUpdate:withDestinationIndexPath:\":(t,e,i)=>{let s=$objc(\"UITableViewDropProposal\").$alloc();return e.$localDragSession()?s.$initWithDropOperation_intent(3,1):s.$initWithDropOperation_intent(2,1),s},\"tableView:performDropWithCoordinator:\":(t,e)=>{e.$session().$localDragSession()?this.reorder(e):this.dropItems(e)}}})}setDelegate(){let t=$(this.views.listId).ocValue();this.initReuseIdentifier(t),t.$setDelegate(this.delegate()),t.$setDragDelegate(this.dragDelegate()),t.$setDropDelegate(this.dropDelegate())}}}),a(\"gVMQa\",function(t,e){var i=n(\"gxpqj\"),s=i.NavigationView,a=i.Sheet,r=n(\"7TSVv\"),o=n(\"2VUvw\"),l=n(\"42nBp\"),h=n(\"kgD3J\"),c=n(\"r5Q7t\");t.exports=class extends r{collectionView;placeholderReuseIdentifier=\"UICollectionViewPlaceholderReuseIdentifier\";cellReuseIdentifier=\"ActionCollectionViewCellReuseIdentifier\";headerReuseIdentifier=\"ActionViewCustomHeaderReuseIdentifier\";footerReuseIdentifier=\"ActionViewCustomFooterReuseIdentifier\";constructor(...t){super(...t),this.views=new h(this.kernel,this),this.delegates=new c(this.kernel,this,this.views)}get actionList(){return super.actions.map(t=>{let e=[];return t.items.forEach(t=>{e.push(this.views.actionToData(t))}),{title:t.title,items:e}})}actionSyncStatus(){$app.listen({actionSyncStatus:t=>{if(t.status===o.status.syncing&&t.animate)this.updateNavButton(!0),this.updateSyncLabel($l10n(\"SYNCING\"));else if(t.status===o.status.success||t.status===o.status.nochange)try{this.applySnapshotAnimatingDifferences()}catch(t){this.kernel.logger.error(t),this.updateSyncLabel(t)}finally{this.updateSyncLabel(),this.updateNavButton(!1),this.collectionView.jsValue().endRefreshing()}}})}editActionInfoPageSheet(t,e){new l(this,t).editActionInfoPageSheet(e)}editActionMainJs(t=\"\",e){new l(this,e).editActionMainJs(t)}getNavButtons(){let t=[{title:$l10n(\"IMPORT_FROM_FILE\"),handler:async()=>{let t=await $drive.open();try{this.importAction(JSON.parse(t.string)),this.applySnapshotAnimatingDifferences()}catch(t){this.kernel.logger.error(t)}}}],e=[{title:$l10n(\"CREATE_NEW_ACTION\"),handler:()=>{this.editActionInfoPageSheet(null,async t=>{let e=$file.read(`${this.actionPath}/template.js`).string;this.saveMainJs(t,e);let i=this.getActionCategorySection(t.category);this.applySnapshotToSectionAnimatingDifferences(i),await $wait(.3),this.editActionMainJs(e,t)})}},{title:$l10n(\"CREATE_NEW_TYPE\"),handler:()=>this.addActionCategory()},{inline:!0,items:t}];return[{symbol:\"plus.circle\",id:this.views.addActionButtonId,menu:{pullDown:!0,asPrimary:!0,items:e}}]}updateSyncLabel(t){t||(t=$l10n(\"MODIFIED\")+this.getLocalSyncDate().toLocaleString()),$(this.views.syncLabelId)&&($(this.views.syncLabelId).text=t)}updateNavButton(t){let e=this.navigationView?.navigationBarItems?.getButton(this.views.addActionButtonId);e&&e.setLoading(t);let i=this.navigationView?.navigationBarItems?.getButton(this.views.sortActionButtonId);i&&i.setLoading(t);let s=this.navigationView?.navigationBarItems?.getButton(this.views.syncButtonId);s&&s.setLoading(t)}initReuseIdentifier(){this.collectionView.$registerClass_forCellWithReuseIdentifier($objc(\"UICollectionViewCell\").$class(),this.placeholderReuseIdentifier),this.collectionView.$registerClass_forCellWithReuseIdentifier($objc(\"UICollectionViewCell\").$class(),this.cellReuseIdentifier),this.views.actionViewCustomHeader(),this.collectionView.$registerClass_forSupplementaryViewOfKind_withReuseIdentifier($objc(\"ActionViewCustomHeader\").$class(),\"UICollectionElementKindSectionHeader\",this.headerReuseIdentifier),this.views.actionViewCustomFooter(),this.collectionView.$registerClass_forSupplementaryViewOfKind_withReuseIdentifier($objc(\"ActionViewCustomFooter\").$class(),\"UICollectionElementKindSectionFooter\",this.footerReuseIdentifier)}initDataSource(){let t=$block(\"UICollectionViewCell *, UICollectionView *, NSIndexPath *, id\",(t,e,i)=>{let s=t.$dequeueReusableCellWithReuseIdentifier_forIndexPath(this.cellReuseIdentifier,e);s.$contentView().$setClipsToBounds(!0),s.$contentView().$layer().$setCornerRadius(10);let{section:n,item:a}=e.jsValue(),r=this.views.matrixCell(this.actions[n].items[a]);return s.$contentView().jsValue().add(r),s}),e=$block(\"UICollectionReusableView *, UICollectionView *, NSString *, NSIndexPath *\",(t,e,i)=>{let{section:s}=i.jsValue();if(\"UICollectionElementKindSectionHeader\"!==e.jsValue())return t.$dequeueReusableSupplementaryViewOfKind_withReuseIdentifier_forIndexPath(e,this.footerReuseIdentifier,i);{let n=t.$dequeueReusableSupplementaryViewOfKind_withReuseIdentifier_forIndexPath(e,this.headerReuseIdentifier,i);return n.$titleLabel().$setText(this.actions[s].title),n}}),i=$objc(\"UICollectionViewDiffableDataSource\").$alloc();i.$initWithCollectionView_cellProvider(this.collectionView,t),i.$setSupplementaryViewProvider(e),$objc_retain(i)}applySnapshotUsingReloadData(){let t=$objc(\"NSDiffableDataSourceSnapshot\").$alloc().$init(),e=this.actions;for(let i in t.$appendSectionsWithIdentifiers(e.map(t=>t.dir)),e)t.$appendItemsWithIdentifiers_intoSectionWithIdentifier(e[i].items.map(t=>t.dir),e[i].dir);this.collectionView.$dataSource().$applySnapshotUsingReloadData(t)}applySnapshotAnimatingDifferences(t=!0){let e=$objc(\"NSDiffableDataSourceSnapshot\").$alloc().$init(),i=this.actions;for(let t in e.$appendSectionsWithIdentifiers(i.map(t=>t.dir+t.items.length)),i)e.$appendItemsWithIdentifiers_intoSectionWithIdentifier(i[t].items.map(t=>t.category+t.dir+t.name+t.icon),i[t].dir+i[t].items.length);this.collectionView.$dataSource().$applySnapshot_animatingDifferences(e,t)}applySnapshotToSectionAnimatingDifferences(t,e=!0){let i=$objc(\"NSDiffableDataSourceSectionSnapshot\").$alloc().$init(),{items:s,dir:n}=this.actions[t];n+=s.length,i.$appendItems(s.map(t=>t.category+t.dir+t.name+t.icon)),this.collectionView.$dataSource().$applySnapshot_toSection_animatingDifferences(i,n,e)}getMatrixView(){let t=this.views.getMatrixView({ready:t=>{this.collectionView=t.ocValue(),this.initReuseIdentifier(),this.delegates.setDelegate(),this.delegates.setRefreshControl(),this.initDataSource(),this.applySnapshotUsingReloadData()}});return this.actionSyncStatus(),t}getPage(){return this.navigationView=new s,this.navigationView.navigationBarItems.setRightButtons(this.getNavButtons()),this.navigationView.setView(this.getMatrixView()).navigationBarTitle($l10n(\"ACTIONS\")),this.navigationView.getPage()}present(){let t=new a,e=this.getNavButtons();t.setView(this.getMatrixView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{symbol:\"xmark.circle\"},rightButtons:e}).init(),this.navigationView=t.navigationView,t.present()}}}),a(\"7TSVv\",function(t,e){var i=n(\"gxpqj\"),s=i.FileStorage,a=i.UIKit,r=n(\"eSp9Z\"),o=r.ActionEnv,l=r.ActionData,h=r.Action,c=n(\"jVlss\").SecureScript,d=n(\"7pN8M\"),u=n(\"2aNLD\").KeyboardPinActions,p=n(\"ilpYs\").TodayPinActions;t.exports=class{#C;#k;constructor(t){this.kernel=t,this.actionPath=\"scripts/action\",this.actionOrderFile=\"order.json\",this.userActionPath=`${this.kernel.fileStorage.basePath}/user_action`,this.localSyncFile=this.userActionPath+\"/sync.json\",this.checkUserAction(),this.initWebdavSync(),this.sync()}get actions(){return this.#C||this.#D(),this.#C}get allActions(){return this.#k||this.#D(),this.#k}get isNew(){return $cache.get(\"caio.action.isNew\")??!1}set isNew(t){$cache.get(\"caio.action.isNew\",t)}#D(){this.#C=this.getActionCategories().map(t=>({category:t,dir:t,title:this.getCategoryTitle(t),items:this.getActions(t)})),this.#k={},this.#C.map(t=>t.items.forEach(t=>{this.#k[t.name]=t})),this.kernel.logger.info(\"init actions\")}importExampleAction(){try{Object.keys(__ACTIONS__).forEach(t=>{Object.keys(__ACTIONS__[t]).forEach(e=>{let i=__ACTIONS__[t][e],s=JSON.parse(i.config);this.exists(s.name)||this.importAction(i,t,!1)})})}catch{$file.list(this.actionPath).forEach(t=>{let e=`${this.actionPath}/${t}`;if($file.isDirectory(e)){let i=`${this.userActionPath}/${t}`;$file.list(e).forEach(t=>{let s=JSON.parse($file.read(`${e}/${t}/config.json`).string);this.exists(s.name)||($file.mkdir(i),$file.copy({src:`${e}/${t}`,dst:`${i}/${t}`}))})}})}this.setNeedReload()}exportAction(t){let e=a.loading();e.start();let{category:i,dir:s,name:n}=t,r=this.actionToString(i,s);e.end(),$share.sheet([{name:n+\".json\",data:$data({string:r})}])}importAction(t,e=\"uncategorized\",i=!0){let n=i?a.loading():null;n?.start();try{let{config:i,main:n,readme:a}=t;if(!i||!n||!a)throw Error(\"Not an action\");let r=JSON.parse(i)?.name?.trim();if(!r||\"\"===r)throw Error(\"Not an action\");let o=this.initActionDirByName(r),l=this.getActionPath(e,o);return $file.mkdir(l),$file.write({data:$data({string:i}),path:s.join(l,\"config.json\")}),$file.write({data:$data({string:n}),path:s.join(l,\"main.js\")}),$file.write({data:$data({string:a}),path:s.join(l,\"README.md\")}),this.setNeedReload(!0),o}catch(t){throw t}finally{n?.end()}}checkUserAction(){$file.exists(this.userActionPath)&&0!==$file.list(this.userActionPath).length||($file.mkdir(this.userActionPath),this.isNew=!1,this.importExampleAction())}getLocalSyncDate(){return new Date(JSON.parse($file.read(this.localSyncFile)?.string??\"{}\").timestamp)}async initWebdavSync(){if(this.kernel.isWebdavEnabled)try{this.webdavSync=new d({kernel:this.kernel,host:this.kernel.setting.get(\"webdav.host\"),user:this.kernel.setting.get(\"webdav.user\"),password:this.kernel.setting.get(\"webdav.password\"),basepath:this.kernel.setting.get(\"webdav.basepath\")}),await this.webdavSync.init()}catch(t){throw this.kernel.logger.error(`${t}\n${t.stack}`),t}}setNeedReload(t){if(this.#C=void 0,this.#k=void 0,this.applySnapshotAnimatingDifferences(t),this.webdavSync)try{this.webdavSync.needUpload()}catch(t){$ui.alert({title:$l10n(\"ALERT\"),message:$l10n(\"WEBDAV_ERROR_CLOSED\")}),this.kernel.setting.set(\"webdav.status\",!1)}}async sync(){this.webdavSync&&this.webdavSync.sync()}updatePinActions(t,e){u.shared.setKernel(this.kernel).updateAction(t,e),p.shared.setKernel(this.kernel).updateAction(t,e)}actionToString(t,e){return JSON.stringify({config:this.getActionConfigString(t,e),main:this.getActionMainJs(t,e),readme:this.getActionReadme(t,e)})}defaultCategories(){return[\"uncategorized\",\"clipboard\",\"editor\"]}getActionCategories(){let t=this.defaultCategories();return t.concat($file.list(this.userActionPath).filter(e=>$file.isDirectory(`${this.userActionPath}/${e}`)&&0>t.indexOf(e)))}async deleteActionCategory(t){let e=`${this.userActionPath}/${t}`,i=await $ui.alert({title:$l10n(\"delete.category\").replace(\"${category}\",t),message:$l10n(\"delete.category.keep.actions\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"DELETE\"),style:$alertActionType.destructive},{title:$l10n(\"CANCEL\")}]});if(2===i.index)return!1;if(0===i.index)for(let t of $file.list(e))$file.move({src:`${e}/${t}`,dst:`${this.userActionPath}/uncategorized/${t}`});return $file.delete(e),this.setNeedReload(),!0}addActionCategory(){$input.text({text:\"\",placeholder:$l10n(\"CREATE_NEW_TYPE\"),handler:t=>{if(\"\"===(t=t.trim())){$ui.toast($l10n(\"INVALID_VALUE\"));return}let e=`${this.userActionPath}/${t}`;$file.isDirectory(e)&&$ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")),$file.mkdir(e),$ui.success($l10n(\"SUCCESS\")),this.setNeedReload()}})}async renameActionCategory(t){let e=await $input.text({text:t});if(\"\"===(e=e.trim()))return $ui.toast($l10n(\"INVALID_VALUE\")),!1;let i=`${this.userActionPath}/${t}`,s=`${this.userActionPath}/${e}`;return $file.isDirectory(s)?($ui.warning($l10n(\"TYPE_ALREADY_EXISTS\")),!1):($file.move({src:i,dst:s}),$ui.success($l10n(\"SUCCESS\")),this.setNeedReload(),!0)}getActionCategorySection(t){for(let e in this.actions)if(this.actions[e].dir===t)return e;return null}getActionOrder(t,e=!1){let i=`${this.userActionPath}/${t}`,s=`${i}/${this.actionOrderFile}`;if($file.exists(s)){let e=JSON.parse($file.read(s).string),n=e.filter(t=>!!$file.exists(`${i}/${t}`));return n.length!==e.length&&this.saveOrder(t,n),n}if(!e)return[];{let t=[];return $file.list(i).forEach(e=>{t.push(e)}),t}}getActionPath(t,e){return`${this.userActionPath}/${t}/${e}`}getActionConfigString(t,e){return $file.read(`${this.getActionPath(t,e)}/config.json`).string}getActionConfig(t,e){return JSON.parse(this.getActionConfigString(t,e))}getActionMainJs(t,e){return $file.read(`${this.getActionPath(t,e)}/main.js`).string}getActionReadme(t,e){return $file.read(`${this.getActionPath(t,e)}/README.md`).string}initActionDirByName(t){return $text.MD5(t)}getActionDirByName(t){return this.allActions[t].dir}getAction(t,e,i){$file.exists(this.getActionPath(t,e))||(e=this.initActionDirByName(e));try{let s=this.getActionMainJs(t,e),n=new c(s);return new(Function(\"Action\",\"ActionEnv\",\"ActionData\",`${n.secure()}\n return MyAction`)(h,o,l))(this.kernel,this.getActionConfig(t,e),i)}catch(t){throw this.kernel.logger.error(t),t}}getActionHandler(t,e){return async i=>{try{let s=this.getAction(t,e,i);return await s.do()}catch(t){throw this.kernel.logger.error(t),t}}}getActions(t){let e=[],i=`${this.userActionPath}/${t}`;if(!$file.exists(i))return[];let s=s=>{let n=`${i}/${s}/`;if($file.isDirectory(n)){let i=this.getActionConfig(t,s);e.push(Object.assign(i,{category:t,dir:s}))}},n=this.getActionOrder(t);return n.forEach(t=>s(t)),$file.list(i).forEach(t=>{-1===n.indexOf(t)&&s(t)}),e}getCategoryTitle(t){let e=t.toUpperCase(),i=$l10n(e);return i===e?t:i}#B(t,...e){let i;\"string\"!=typeof t&&(t=JSON.stringify(t));let n=s.join(this.userActionPath,...e),a=n.substring(0,n.lastIndexOf(\"/\"));$file.exists(a)||$file.mkdir(a);let r=$file.read(n)?.string;try{i=JSON.stringify(JSON.parse(r))}catch{i=r}t!==i&&$file.write({data:$data({string:t}),path:n})}changeCategory(t,e){$file.move({src:`${this.userActionPath}/${t.category}/${t.dir}`,dst:`${this.userActionPath}/${e.category}/${e.dir}`})}saveActionInfo(t,e){t&&(t.category!==e.category&&this.changeCategory(t,e),this.updatePinActions(t,e)),this.#B({icon:e.icon,color:e.color,name:e.name},e.category,e.dir,\"config.json\"),this.#B(e.readme,e.category,e.dir,\"README.md\"),this.setNeedReload(!0)}saveMainJs(t,e){this.#B(e,t.category,t.dir,\"main.js\"),this.setNeedReload()}saveOrder(t,e){this.#B(JSON.stringify(e),t,this.actionOrderFile),this.setNeedReload()}move(t,e){if(t.section===e.section&&t.item===e.item)return;let i=this.actions[t.section],s=i.items,n=i.dir,a=t=>t.map(t=>t.dir);if(t.section===e.section){let i=t.iteme.item?t.item+1:t.item;s.splice(i,0,s[t.item]),s=s.filter((t,e)=>e!==r),this.saveOrder(n,a(s))}else{let i=this.actions[e.section],r=i.items,o=i.dir;r.splice(e.item,0,s[t.item]),s=s.filter((e,i)=>i!==t.item);let l=r[e.item],h=Object.assign(JSON.parse(JSON.stringify(r[e.item])),{category:o});this.changeCategory(l,h),this.updatePinActions(l,h),this.saveOrder(o,a(r)),this.saveOrder(n,a(s))}this.setNeedReload()}delete(t){$file.delete(`${this.userActionPath}/${t.category}/${t.dir}`),this.setNeedReload(!0)}exists(t){return void 0!==this.allActions[t]}}}),a(\"7pN8M\",function(t,e){var i=n(\"gxpqj\").FileStorage,s=n(\"2VUvw\");class a extends s{localSyncDataPath=\"/user_action/sync.json\";webdavSyncDataPath=\"/sync.json\";tempPath=\"/temp\";webdavActionsPath=\"/actions.zip\";localActionsPath=\"/user_action\";constructor({host:t,user:e,password:s,basepath:n,kernel:a}={}){super({host:t,user:e,password:s,basepath:n=i.join(n,\"user_action\"),kernel:a})}async init(){await super.init(),this.sync()}isNew(){return this.kernel.actions.isNew}async pull(){let t=i.join(this.tempPath,\"user_action\"),e=this.kernel.fileStorage.filePath(t),s=await this.webdav.get(this.webdavActionsPath);if(!await $archiver.unzip({file:s.rawData,dest:e}))throw Error($l10n(\"UNZIP_FAILED\"));await this.downloadSyncData(),this.kernel.fileStorage.move(t,this.localActionsPath),this.kernel.logger.info(\"action webdav sync: pulled\")}async push(){let t=i.join(this.tempPath,\"actions.zip\");if(!$archiver.zip({directory:this.kernel.fileStorage.filePath(this.localActionsPath),dest:this.kernel.fileStorage.filePath(t)}))throw Error($l10n(\"ZIP_FAILED\"));await $wait(.5),await this.webdav.put(this.webdavActionsPath,this.kernel.fileStorage.readSync(t)),await this.uploadSyncData(),this.kernel.fileStorage.delete(t),this.kernel.logger.info(\"action webdav sync: pushed\")}notify(t){$app.notify({name:\"actionSyncStatus\",object:t})}async #u(){let t=!1;try{let e=await this.nextSyncStep();if(this.kernel.logger.info(`action nextSyncStep: ${s.stepName[e]}`),e===s.step.needPush||e===s.step.init)await this.push();else if(e===s.step.needPull)await this.pull(),t=!0;else if(e===s.step.conflict){if(await this.conflict($l10n(\"ACTIONS\"))!==a.conflictKeep.webdav)return;t=!0}else{this.notify({status:s.status.nochange});return}this.notify({status:s.status.success,updateList:t})}catch(t){throw this.notify({status:s.status.fail,error:t}),t}}sync(){this.notify({status:s.status.syncing,animate:!0}),this.syncTimer&&this.syncTimer.cancel(),this.syncTimer=$delay(.5,()=>{this.#u(!0)})}needUpload(){this.notify({status:s.status.syncing}),this.uploadTimer&&this.uploadTimer.cancel(),this.uploadTimer=$delay(.5,()=>{this.updateLocalTimestamp(),this.#u()})}}t.exports=a}),a(\"2aNLD\",function(t,e){var i=n(\"gxpqj\").Sheet,s=n(\"3VDld\").SelectActions;class a{constructor(){this.listId=\"keyboard-script-list\"}static getAddins(){let t=$cache.get(\"keyboard.addins\");if(!t)return[];if($cache.get(\"keyboard.addins.all\")){let t=$addin.current.name;return $addin.list?.filter(e=>t!==e.displayName).map(t=>t.displayName)}try{return JSON.parse(t)}catch(t){return[]}}static setAddins(t=[]){t.map((e,i)=>{null===e&&t.splice(i,1)});try{$cache.set(\"keyboard.addins\",JSON.stringify(t))}catch(t){$cache.set(\"keyboard.addins\",void 0)}}static setAllAddins(t){$cache.set(\"keyboard.addins.all\",t)}getUnsetAddins(){let t=$addin.current.name,e=a.getAddins();return $addin.list?.filter(i=>e.indexOf(i.displayName)===-1&&t!==i.displayName).map(t=>t.displayName)}add(){let t={type:\"list\",props:{data:this.getUnsetAddins()},events:{didSelect:(t,e,i)=>{let s=a.getAddins();s.unshift(i),a.setAddins(s),$(this.listId).insert({indexPath:$indexPath(0,0),value:i}),t.delete(e)}},layout:$layout.fill};new i().setView(t).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!0,data:a.getAddins(),actions:[{title:\"delete\",handler:(t,e)=>{a.setAddins(t.data)}}]},events:{reorderFinished:t=>{a.setAddins(t)}},layout:$layout.fill}}async sheet(){if(0===(await $ui.menu({items:[$l10n(\"ALL_SCRIPTS\"),$l10n(\"SELECT_SCRIPTS\")]})).index)a.setAllAddins(!0);else{a.setAllAddins(!1);let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"QUICK_START_SCRIPTS\"),popButton:{title:$l10n(\"DONE\")},rightButtons:this.getNavButtons()}),t.init().present()}}}class r extends s{static shared=new r;cacheKey=\"keyboard.pinAction\";constructor(t){super(t),this.listId=\"keyboard-pin-action-list\"}async sheet(){let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"PIN_ACTION\"),popButton:{title:$l10n(\"DONE\")},rightButtons:this.getNavButtons()}),t.init().present()}}t.exports={KeyboardAddins:a,KeyboardPinActions:r}}),a(\"3VDld\",function(t,e){var i=n(\"gxpqj\").Sheet;class s{static shared=new s;cacheKey;constructor(t){this.kernel=t}setKernel(t){return this.kernel=t,this}getActions(){let t=$cache.get(this.cacheKey);return Array.isArray(t)?t.filter(t=>this.kernel.actions.exists(t.name)):[]}addAction(t){let e=this.getActions();e.push(t),$cache.set(this.cacheKey,e)}setActions(t=[]){$cache.set(this.cacheKey,t)}updateAction(t,e){this.setActions(this.getActions().map(i=>i.category===t.category&&i.dir===t.dir?e:i))}add(){let t=\"keyboard.add.sheet\",e=()=>{let t=this.getActions().map(t=>t.name),e=this.kernel.actions.actionList;for(let i=0;i-1===t.indexOf(e.name.text));return e.map(t=>(t.rows=t.items,t)),e},s=this.kernel.actions.views.getActionListView((i,s)=>{this.addAction(s),$(this.listId).data=this.getListData(),$(t).data=e()},{id:t,bgcolor:$color(\"primarySurface\"),stickyHeader:!1,data:e()},{},$layout.fill);new i().setView(s).addNavBar({title:$l10n(\"ADD\")}).init().present()}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.add()}]}getListData(t=this.getActions()){return t.map(t=>this.kernel.actions.views.actionToData(t))}getListView(){return this.kernel.actions.views.getActionListView(void 0,{id:this.listId,bgcolor:$color(\"primarySurface\"),stickyHeader:!1,reorder:!0,data:this.getListData(),actions:[{title:\"delete\",handler:(t,e)=>{let i=t.data;this.setActions(i.map(t=>t.info.info))}}]},{reorderFinished:t=>{this.setActions(t.map(t=>t.info.info))}},$layout.fill)}async sheet(){let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"PIN_ACTION\"),popButton:{title:$l10n(\"DONE\")},rightButtons:this.getNavButtons()}),t.init().present()}}t.exports={SelectActions:s}}),a(\"ilpYs\",function(t,e){var i=n(\"gxpqj\").Sheet,s=n(\"3VDld\").SelectActions;class a extends s{static shared=new a;cacheKey=\"today.actions\";constructor(t){super(t),this.listId=\"today-action-list\"}sheet(){let t=new i;t.setView(this.getListView()).addNavBar({title:$l10n(\"ACTIONS\"),popButton:{title:$l10n(\"CLOSE\")},rightButtons:this.getNavButtons()}),t.init().present()}}t.exports={TodayPinActions:a}}),a(\"42nBp\",function(t,e){var i=n(\"gxpqj\"),s=i.Setting,a=i.Sheet,r=n(\"f0nX9\"),o=n(\"eSp9Z\"),l=o.ActionEnv,h=o.ActionData;t.exports=class{editingActionInfo;constructor(t,e){this.data=t,this.info=e,this.raw=JSON.parse(JSON.stringify(e)),this.actionCategories=this.data.getActionCategories(),this.initEditingActionInfo(),this.initSettingInstance()}initEditingActionInfo(){this.isNew=!this.info,this.isNew?this.editingActionInfo={category:this.actionCategories[0],name:\"MyAction\",color:\"#CC00CC\",icon:\"icon_062.png\",readme:\"\"}:(this.editingActionInfo=this.info,this.editingActionInfo.readme=this.data.getActionReadme(this.info.category,this.info.dir))}initSettingInstance(){this.settingInstance=new s({structure:[],set:(t,e)=>(this.editingActionInfo[t]=e,!0),get:(t,e=null)=>Object.prototype.hasOwnProperty.call(this.editingActionInfo,t)?this.editingActionInfo[t]:e})}informationView(){let t=this.settingInstance.loader({setting:this.settingInstance,type:\"input\",key:\"name\",icon:[\"pencil.circle\",\"#FF3366\"],title:$l10n(\"NAME\")}).create(),e=this.settingInstance.loader({setting:this.settingInstance,type:\"color\",key:\"color\",icon:[\"pencil.tip.crop.circle\",\"#0066CC\"],title:$l10n(\"COLOR\")}).create();return[t,e,this.settingInstance.loader({setting:this.settingInstance,type:\"icon\",key:\"icon\",icon:[\"star.circle\",\"#FF9933\"],title:$l10n(\"ICON\"),bgcolor:this.data.views.getColor(this.editingActionInfo.color)}).create(),this.settingInstance.loader({setting:this.settingInstance,type:\"menu\",key:\"category\",icon:[\"tag.circle\",\"#33CC33\"],title:$l10n(\"CATEGORY\"),items:this.actionCategories,values:this.actionCategories,pullDown:!0}).create()]}actionInfoView(){let t={type:\"view\",views:[{type:\"text\",props:{id:\"action-text\",textColor:$color(\"#000000\",\"secondaryText\"),bgcolor:$color(\"systemBackground\"),text:this.editingActionInfo.readme,insets:$insets(10,10,10,10)},layout:$layout.fill,events:{tapped:t=>{$(\"actionInfoPageSheetList\").scrollToOffset($point(0,this.isNew?280:230)),$delay(.2,()=>t.focus())},didChange:t=>{this.editingActionInfo.readme=t.text}}}],layout:$layout.fill},e=[{title:$l10n(\"INFORMATION\"),rows:this.informationView()},{title:$l10n(\"DESCRIPTION\"),rows:[t]}];return{type:\"list\",props:{id:\"actionInfoPageSheetList\",bgcolor:$color(\"insetGroupedBackground\"),style:2,separatorInset:$insets(0,50,0,10),data:e},layout:$layout.fill,events:{rowHeight:(t,e)=>1===e.section?120:50}}}editActionInfoPageSheet(t){let e=new a,i=async()=>{!(this.isNew&&(this.editingActionInfo.dir=this.data.initActionDirByName(this.editingActionInfo.name),this.data.exists(this.editingActionInfo.name)&&1===(await $ui.alert({title:$l10n(\"UNABLE_CREATE_ACTION\"),message:$l10n(\"ACTION_NAME_ALREADY_EXISTS\").replaceAll(\"${name}\",this.editingActionInfo.name)})).index))&&(e.dismiss(),this.data.saveActionInfo(this.raw,this.editingActionInfo),await $wait(.3),t&&t(this.editingActionInfo))};e.setView(this.actionInfoView()).addNavBar({title:\"\",popButton:{title:$l10n(\"CANCEL\")},rightButtons:[{title:$l10n(\"DONE\"),tapped:()=>i()}]}).init().present()}editorNavButtons(t){return[{symbol:\"book.circle\",tapped:()=>{let t=$file.read(\"scripts/action/README.md\")?.string;if(!t)try{t=__ACTION_README__.content}catch{}new a().setView({type:\"markdown\",props:{content:t},layout:(t,e)=>{t.size.equalTo(e.super)}}).addNavBar({title:\"Document\",popButton:{symbol:\"x.circle\"}}).init().present()}},{symbol:\"play.circle\",tapped:async()=>{try{this.data.saveMainJs(this.info,t.text);let e=await this.data.getActionHandler(this.info.category,this.info.dir)(new h({env:l.build}));void 0!==e&&(\"object\"==typeof e&&(e=JSON.stringify(e,null,2)),new a().setView({type:\"code\",props:{lineNumbers:!0,editable:!1,text:e},layout:$layout.fill}).addNavBar({title:\"\",popButton:{title:$l10n(\"DONE\")}}).init().present())}catch(t){this.data.kernel.logger.error(t)}}}]}editActionMainJs(t=\"\"){let e=new r(this.data.kernel);e.pageSheet(t,t=>{this.data.saveMainJs(this.info,t)},this.info.name,this.editorNavButtons(e),\"code\")}}}),a(\"kgD3J\",function(t,e){var i=n(\"gxpqj\"),s=i.BarButtonItem,a=i.UIKit;t.exports=class{addActionButtonId=\"action-manager-button-add\";sortActionButtonId=\"action-manager-button-sort\";syncButtonId=\"action-manager-button-sync\";syncLabelId=\"action-manager-sync-label\";editingToolBarId=\"action-editingToolBarId\";horizontalMargin=20;verticalMargin=14;editModeToolBarHeight=44;columns=2;spacing=15;itemHeight=100;headerHeight=35;constructor(t,e){this.kernel=t,this.data=e}getActionListView(t,e={},i={},s){return t&&(i.didSelect=(e,i,s)=>{let n=s.info.info;t(this.data.getActionHandler(n.category,n.dir),n)}),{type:\"list\",layout:(t,e)=>{\"function\"==typeof s?s(t,e):(t.top.width.equalTo(e.super.safeArea),t.bottom.inset(0))},events:i,props:Object.assign({reorder:!1,bgcolor:$color(\"clear\"),rowHeight:60,sectionTitleHeight:30,stickyHeader:!0,data:(()=>{let t=this.data.actionList;return t.map(t=>(t.rows=t.items,t)),t})(),template:{props:{bgcolor:$color(\"clear\")},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(15),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(20),t.size.equalTo($size(20,20))}},{type:\"label\",props:{id:\"name\",lines:1,font:$font(16)},layout:(t,e)=>{t.height.equalTo(30),t.centerY.equalTo(e.super),t.left.equalTo(e.prev.right).offset(15)}},{type:\"label\",props:{id:\"info\"}}]}},e)}}getActionMiniView(t,e){return e||(e=[],this.data.actions.forEach(t=>{e=e.concat(t.items)})),{type:\"matrix\",props:{bgcolor:$color(\"clear\"),columns:2,itemHeight:50,spacing:8,data:e.map(t=>this.actionToData(t)),template:{props:{smoothCorners:!0,cornerRadius:10,bgcolor:$color($rgba(255,255,255,.3),$rgba(0,0,0,.3))},views:[{type:\"image\",props:{id:\"color\",cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:{id:\"icon\",tintColor:$color(\"#ffffff\")},layout:(t,e)=>{t.edges.equalTo(e.prev).insets(5)}},{type:\"label\",props:{id:\"name\",font:$font(14)},layout:(t,e)=>{t.bottom.top.inset(10),t.left.equalTo(e.prev.prev.right).offset(10),t.right.inset(10)}},{type:\"view\",props:{id:\"info\",hidden:!0}}]}},layout:$layout.fill,events:{didSelect:async(e,i,s)=>{let n=s.info.info,a=await t(n);this.data.getActionHandler(n.category,n.dir)(a)}}}}getMatrixEditModeToolBarView({selectButtonEvents:t,deleteButtonEvents:e}={}){return a.blurBox({id:this.editingToolBarId},[a.separatorLine(),{type:\"view\",views:[{type:\"button\",props:{id:this.editingToolBarId+\"-select-button\",title:$l10n(\"SELECT_ALL\"),titleColor:$color(\"tint\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.left.inset(this.horizontalMargin),t.centerY.equalTo(e.super)},events:t},{type:\"button\",props:{id:this.editingToolBarId+\"-delete-button\",symbol:\"trash\",hidden:!0,tintColor:$color(\"red\"),bgcolor:$color(\"clear\")},layout:(t,e)=>{t.height.equalTo(e.super),t.width.equalTo(2*this.horizontalMargin),t.right.inset(this.horizontalMargin/2),t.centerY.equalTo(e.super)},events:e}],layout:(t,e)=>{t.left.right.top.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom)}}])}getColor(t,e=null){return t?\"string\"==typeof t?$color(t):$rgba(t.red,t.green,t.blue,t.alpha):e}actionToData(t){return{name:{text:t.name},icon:t?.icon?.slice(0,5)===\"icon_\"?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t?.icon)},color:{bgcolor:this.getColor(t.color)},info:{info:t}}}matrixCell(t){return{props:{bgcolor:$color(\"#ffffff\",\"#242424\")},views:[{type:\"image\",props:{bgcolor:this.getColor(t.color),cornerRadius:8,smoothCorners:!0},layout:t=>{t.top.left.inset(10),t.size.equalTo($size(30,30))}},{type:\"image\",props:Object.assign({tintColor:$color(\"#ffffff\")},t?.icon?.slice(0,5)===\"icon_\"?{icon:$icon(t.icon.slice(5,t.icon.indexOf(\".\")),$color(\"#ffffff\"))}:{image:$image(t?.icon)}),layout:t=>{t.top.left.inset(15),t.size.equalTo($size(20,20))}},{type:\"button\",props:{bgcolor:$color(\"clear\"),tintColor:a.textColor,titleColor:a.textColor,contentEdgeInsets:$insets(0,0,0,0),titleEdgeInsets:$insets(0,0,0,0),imageEdgeInsets:$insets(0,0,0,0)},views:[{type:\"image\",props:{symbol:\"ellipsis.circle\"},layout:(t,e)=>{t.center.equalTo(e.super),t.size.equalTo(s.style.iconSize)}}],events:{tapped:e=>{let i=this.data.getActionMainJs(t.category,t.dir);this.data.editActionMainJs(i,t)}},layout:t=>{t.top.right.inset(0),t.size.equalTo(s.style.width)}},{type:\"label\",props:{text:t.name,font:$font(16)},layout:(t,e)=>{t.bottom.left.inset(10),t.width.equalTo(e.super)}}],layout:$layout.fill}}actionViewCustomHeader(){$define({type:\"ActionViewCustomHeader: UICollectionReusableView\",props:[\"titleLabel\"],events:{\"initWithFrame:\":t=>{let e=(self=self.$super().$initWithFrame(t)).$bounds();e.x=this.spacing,e.y=this.headerHeight-21;let i=$objc(\"UILabel\").$alloc().$initWithFrame(e);return i.$setFont($font(\"bold\",21).ocValue()),i.$setTextAlignment($align.left),i.$setNumberOfLines(1),self.$setTitleLabel(i),self.$addSubview(self.$titleLabel()),self}}})}actionViewCustomFooter(){$define({type:\"ActionViewCustomFooter: UICollectionReusableView\",props:[\"titleLabel\"],events:{\"initWithFrame:\":t=>{let e=(self=self.$super().$initWithFrame(t)).$bounds();e.x=this.spacing;let i=$objc(\"UILabel\").$alloc().$initWithFrame(e);return i.$setFont($font(16).ocValue()),i.$setTextAlignment($align.left),self.$setTitleLabel(i),self.$addSubview(self.$titleLabel()),self}}})}collectionViewFlowLayout(){let t=$objc(\"UICollectionViewFlowLayout\").$alloc().$init();t.$setScrollDirection($scrollDirection.vertical),t.$setMinimumLineSpacing(this.spacing),t.$setMinimumInteritemSpacing(this.spacing);let e=$insets(this.spacing,this.spacing,0,this.spacing).ocValue();return t.$setSectionInset(e.$UIEdgeInsetsValue()),t}getMatrixView(t){return{type:\"matrix\",props:{bgcolor:a.scrollViewBackgroundColor},layout:$layout.fill,events:t}}}}),a(\"r5Q7t\",function(t,e){var i=n(\"gxpqj\"),s=i.UIKit,a=i.Sheet,r=n(\"eSp9Z\"),o=r.ActionEnv,l=r.ActionData;t.exports=class{collectionView;#x;constructor(t,e,i){this.kernel=t,this.data=e,this.views=i}getActionByIndexPath(t){let e=t.$section(),i=t.$item();return this.data.actions[e].items[i]}get matrixSelected(){let t=this.collectionView?.$indexPathsForSelectedItems()?.jsValue();return Array.isArray(t)?t:[]}get menu(){return{items:[{title:$l10n(\"EDIT_DETAILS\"),symbol:\"slider.horizontal.3\",handler:(t,e,i)=>{this.data.editActionInfoPageSheet(i,t=>{this.data.applySnapshotToSectionAnimatingDifferences(e.$section())})}},{title:$l10n(\"EDIT_SCRIPT\"),symbol:\"square.and.pencil\",handler:(t,e,i)=>{let s=this.data.getActionMainJs(i.category,i.dir);this.data.editActionMainJs(s,i)}},{inline:!0,items:[{title:\"README\",symbol:\"book\",handler:(t,e,i)=>{let s;try{s=__ACTIONS__[i.category][i.dir][\"README.md\"]}catch{s=this.data.getActionReadme(i.category,i.dir)}new a().setView({type:\"markdown\",props:{content:s},layout:(t,e)=>{t.size.equalTo(e.super)}}).init().present()}}]},{inline:!0,items:[{title:$l10n(\"SHARE\"),symbol:\"square.and.arrow.up\",handler:(t,e,i)=>{this.data.exportAction(i)}},{title:$l10n(\"DELETE\"),symbol:\"trash\",destructive:!0,handler:(t,e,i)=>{s.deleteConfirm($l10n(\"DELETE_CONFIRM_MSG\"),()=>{this.data.delete(i),this.data.applySnapshotToSectionAnimatingDifferences(e.$section())})}}]}]}}setEditingCallback(t){this.#x=t}createUIMenu=({title:t,image:e,actions:i,inline:s=!1,destructive:n=!1}={})=>{let a;return s&&(a|=1),n&&(a|=2),$objc(\"UIMenu\").$menuWithTitle_image_identifier_options_children(t??\"\",e,null,a??0,i)};createUIAction=({title:t,image:e,handler:i,destructive:s=!1}={})=>{let n=$objc(\"UIAction\").$actionWithTitle_image_identifier_handler(t,e,null,$block(\"void, UIAction *\",t=>{i(t)}));return s&&n.$setAttributes(2),n};createUICollectionViewDropPlaceholder(t){let e=$objc(\"UICollectionViewDropPlaceholder\").$alloc();return e.$initWithInsertionIndexPath_reuseIdentifier(t,this.data.placeholderReuseIdentifier),e}updateEditingToolBar(){let t=0===this.matrixSelected.length,e=$(this.views.editingToolBarId+\"-select-button\"),i=$(this.views.editingToolBarId+\"-delete-button\");e.title=t?$l10n(\"SELECT_ALL\"):$l10n(\"DESELECT_ALL\"),i.hidden=t}toggleAllSelected(t=!1,e=!0){let i=this.data.clips.length;if(t||0!==this.matrixSelected.length)for(let t=0;t{this.matrixSelected.sort((t,e)=>t.itemthis.toggleAllSelected()},deleteButtonEvents:{tapped:()=>this.deleteSelected()}}));$ui.window.add(t),$(this.views.editingToolBarId).layout((t,e)=>{t.left.right.bottom.equalTo(e.super),t.top.equalTo(e.super.safeAreaBottom).offset(-this.views.editModeToolBarHeight)})}else $(this.views.editingToolBarId).remove()}}didSelectItemAtIndexPath(t,e){if(t.$isEditing()){this.updateEditingToolBar();return}if(t.$hasActiveDrag())return;let i=this.getActionByIndexPath(e),s=new l({env:o.action,text:\"clipboard\"===i.category||\"uncategorized\"===i.category?$clipboard.text:null});this.data.getActionHandler(i.category,i.dir)(s)}didDeselectItemAtIndexPath(t,e){t.$isEditing()&&this.updateEditingToolBar()}contextMenuConfigurationForItemAtIndexPath(t,e,i){if(t.$isEditing())return;let s=i=>{let n=[];return i.items.forEach(i=>{i.items?n.push(s(i)):n.push(this.createUIAction({title:i.title,image:i.symbol,handler:()=>{i.handler(t,e,this.getActionByIndexPath(e))},destructive:i.destructive}))}),this.createUIMenu({title:i.title,image:i.symbol,actions:n,inline:i.inline,destructive:i.destructive})};return $objc(\"UIContextMenuConfiguration\").$configurationWithIdentifier_previewProvider_actionProvider(null,null,$block(\"UIMenu *, NSArray *\",()=>s(this.menu)))}scrollViewDelegate(){let t=this.data.navigationView.view.scrollableView.events;return{\"scrollViewDidScroll:\":e=>{t.didScroll(e.jsValue())},\"scrollViewDidEndDragging:willDecelerate:\":(e,i)=>{t.didEndDragging(e.jsValue(),i)},\"scrollViewDidEndDecelerating:\":e=>{t.didEndDecelerating(e.jsValue())},\"handleRefresh:\":async t=>{this.kernel.setting.get(\"webdav.status\")?this.data.sync():(this.data.applySnapshotAnimatingDifferences(),t.$endRefreshing())}}}setRefreshControl(){let t=$objc(\"UIRefreshControl\").$alloc().$init();if(t.$addTarget_action_forControlEvents(this.collectionView.$delegate(),\"handleRefresh:\",4096),this.kernel.setting.get(\"webdav.status\")){let e=$l10n(\"MODIFIED\")+this.data.getLocalSyncDate().toLocaleString(),i=$objc(\"NSAttributedString\").$alloc().$initWithString(e);t.$setAttributedTitle(i)}this.collectionView.$setRefreshControl(t)}delegate(){return $delegate({type:\"UICollectionViewDelegate, UICollectionViewDelegateFlowLayout\",events:{...this.scrollViewDelegate(),\"collectionView:shouldBeginMultipleSelectionInteractionAtIndexPath:\":(t,e)=>!1,\"collectionView:didSelectItemAtIndexPath:\":(t,e)=>{this.didSelectItemAtIndexPath(t,e)},\"collectionView:didDeselectItemAtIndexPath:\":(t,e)=>{this.didDeselectItemAtIndexPath(t,e)},\"collectionView:contextMenuConfigurationForItemsAtIndexPaths:point:\":(t,e,i)=>this.contextMenuConfigurationForItemAtIndexPath(t,e.$firstObject(),i),\"collectionView:contextMenuConfigurationForItemAtIndexPath:point:\":(t,e,i)=>this.contextMenuConfigurationForItemAtIndexPath(t,e,i),\"collectionView:layout:sizeForItemAtIndexPath:\":(t,e,i)=>{let s=this.views.spacing*(this.views.columns+1);return $size((t.$frame().width-s)/this.views.columns,this.views.itemHeight)},\"collectionView:layout:referenceSizeForHeaderInSection:\":(t,e,i)=>$size(t.$frame().width-2*this.views.spacing,this.views.headerHeight)}})}itemsForBeginningDragSession(t,e){let i=this.getActionByIndexPath(e),s=$objc(\"NSItemProvider\").$alloc().$init();s.$setSuggestedName(i.name+\".json\"),s.$registerDataRepresentationForTypeIdentifier_visibility_loadHandler(\"public.text\",0,$block(\"NSProgress *, block\",t=>(t($data({string:this.data.actionToString(i.category,i.dir)}).ocValue(),null),null)));let n=$objc(\"UIDragItem\").$alloc().$initWithItemProvider(s),a=t.$localContext();if(a)a.$addObject(n);else{let e=NSMutableArray.$new();e.$addObject(n),t.$setLocalContext(e)}return[n]}dragDelegate(){return $delegate({type:\"UICollectionViewDragDelegate\",events:{\"collectionView:itemsForBeginningDragSession:atIndexPath:\":(t,e,i)=>this.itemsForBeginningDragSession(e,i)}})}reorder(t){let e=t.$items().$firstObject(),i=e.$sourceIndexPath().jsValue(),s=t.$destinationIndexPath(),n=s.jsValue();this.data.move(i,n),this.data.applySnapshotAnimatingDifferences(!1),this.data.applySnapshotToSectionAnimatingDifferences(i.section),i.section!==n.section&&this.data.applySnapshotToSectionAnimatingDifferences(n.section),t.$dropItem_toItemAtIndexPath(e.$dragItem(),s)}dropItems(t){let e=t.$destinationIndexPath();if(!e)return;let i=t.$items(),s=i.$count();for(let n=0;n{e&&($ui.alert(e.jsValue()),this.kernel.logger.error(e.jsValue())),r.$commitInsertionWithDataSourceUpdates($block(\"void, NSIndexPath *\",e=>{let i;let s=(e=e.jsValue()).section,n=this.data.getActionCategories(),a=JSON.parse(t.jsValue().string),r=this.data.importAction(a,n[s]),o=this.data.actions[s].items;for(let t in o)if(o[t].dir===r){i=t;break}void 0!==i&&this.data.move($indexPath(s,i),e),this.data.applySnapshotToSectionAnimatingDifferences(s)}))};o.$loadDataRepresentationForTypeIdentifier_completionHandler(l[0],$block(\"void, NSData *, NSError *\",(t,e)=>{$delay(0,()=>h(t,e))}))}}dropDelegate(){return $delegate({type:\"UICollectionViewDropDelegate\",events:{\"collectionView:canHandleDropSession:\":(t,e)=>!t.$isEditing(),\"collectionView:dropSessionDidUpdate:withDestinationIndexPath:\":(t,e,i)=>{let s=$objc(\"UICollectionViewDropProposal\").$alloc();return e.$localDragSession()?s.$initWithDropOperation_intent(3,1):s.$initWithDropOperation_intent(2,1),s},\"collectionView:performDropWithCoordinator:\":(t,e)=>{e.$session().$localDragSession()?this.reorder(e):this.dropItems(e)}}})}setDelegate(){this.collectionView=this.data.collectionView,this.collectionView.$setDelegate(this.delegate()),this.collectionView.$setCollectionViewLayout(this.views.collectionViewFlowLayout()),this.collectionView.$setDragDelegate(this.dragDelegate()),this.collectionView.$setDropDelegate(this.dropDelegate())}}}),a(\"gYDdO\",function(t,e){let i=$app.info.bundleID.includes(\"taio\");class s{files=[];databases=[];actions={};constructor(t){this.kernel=t}deleteFiles(t){t.forEach(t=>{this.files.includes(t)||this.files.push(t)})}#O(){this.files.forEach(t=>{$file.exists(t)&&(this.kernel.logger.info(`delete file: ${t}`),$file.delete(t))})}rebuildDatabase(t,e){this.databases.push([t,e])}#R(){let t=(t,e)=>{let i=this.kernel.storage.sqlite.query(`SELECT count(*), name FROM sqlite_master WHERE type = \"table\" AND name = \"${t}\"`);if(null!==i.error)throw Error(`Code [${i.error.code}] ${i.error.domain} ${i.error.localizedDescription}`);i.result.next();let s=i.result.get(0);i.result.close(),s>0&&(this.kernel.logger.info(`copy data from old table: ${t}`),this.kernel.storage.sqlite.update(`INSERT INTO ${e} SELECT * FROM ${t}`),this.kernel.logger.info(`drop table: ${t}`),this.kernel.storage.sqlite.update(`DROP TABLE ${t}`))};this.databases.forEach(e=>{t(e[0],e[1])})}rebuildUserActions(t={}){for(let e of Object.keys(t))t[e].forEach(t=>{this.actions[e]||(this.actions[e]=[]),this.actions[e].includes(t)||this.actions[e].push(t)})}async #L(){if(0===Object.keys(this.actions).length)return;let t=\"scripts/action\",e=`${this.kernel.fileStorage.basePath}/user_action`,i=[];for(let e of Object.keys(this.actions))this.actions[e].forEach(s=>{let n;let a=`${t}/${e}/${s}/config.json`;$file.exists(a)?n=JSON.parse($file.read(`${t}/${e}/${s}/config.json`).string):n=__INFO__,i.push(n.name)});if(1!==(await $ui.alert({title:$l10n(\"compatibility.rebuildUserAction.alert.title\"),message:$l10n(\"compatibility.rebuildUserAction.alert.message\")+\"\\n\"+JSON.stringify(i,null,2)+\"\\n\"+$l10n(\"compatibility.rebuildUserAction.alert.message2\"),actions:[{title:$l10n(\"OK\")},{title:$l10n(\"CANCEL\")}]})).index){for(let i of Object.keys(this.actions))this.actions[i].forEach(s=>{$file.exists(`${e}/${i}/${s}`)&&(this.kernel.logger.info(`rebuild user action: ${i}/${s}`),$file.copy({src:`${t}/${i}/${s}/main.js`,dst:`${e}/${i}/${s}/main.js`}))});this.kernel.actions.setNeedReload()}}async do(){this.#O(),this.#R(),await this.#L()}}class n{version=13;userVersion=$cache.get(\"compatibility.version\")??0;constructor(t){this.kernel=t,this.compatibility=new s(this.kernel)}do(){if(this.userVersion>0&&this.userVersionthis.kernel.logger.error(t))}$cache.set(\"compatibility.version\",this.version)}call(t){if(\"function\"==typeof this[`ver${t}`])this[`ver${t}`]();else throw ReferenceError(`Version ${t} undefined`)}ver1(){this.compatibility.deleteFiles([\"scripts/action/clipboard/ClearClipboard\",\"scripts/ui/clipboard.js\",\"scripts/ui/clipboard-data.js\",\"scripts/ui/clipboard-search.js\"]),this.compatibility.rebuildDatabase(\"clipboard\",\"clips\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\",\"DisplayClipboard\"],clipboard:[\"B23Clean\"]}),$cache.get(\"caio.keyboard.height\")&&(this.kernel.setting.set(\"keyboard.previewAndHeight\",$cache.get(\"caio.keyboard.height\")),$cache.remove(\"caio.keyboard.height\"))}ver2(){this.compatibility.deleteFiles([\"scripts/storage.js\",\"scripts/ui/clips-data.js\",\"scripts/ui/components/action-manager-data.js\"]),this.compatibility.rebuildDatabase(\"pin\",\"favorite\"),this.compatibility.rebuildUserActions({uncategorized:[\"ExportAllContent\"]})}ver3(){this.compatibility.rebuildUserActions({clipboard:[\"SendToWin\"]})}ver4(){let t=\"/storage/user_action/data.json\";if($file.exists(t)){let e=JSON.parse($file.read(t).string).date;$file.write({data:$data({string:JSON.stringify({timestamp:e})}),path:\"/storage/user_action/sync.json\"}),$file.delete(t)}}ver5(){this.compatibility.rebuildUserActions({uncategorized:[\"DisplayClipboard\"]})}ver6(){this.compatibility.rebuildUserActions({clipboard:[\"GetFromWin\"]})}ver7(){this.compatibility.rebuildUserActions({uncategorized:[\"Replace\"]})}ver8(){}ver9(){this.compatibility.rebuildUserActions({clipboard:[\"SendToWin\"]})}ver10(){let t=this.kernel.fileStorage.basePath;$file.mkdir(t),$file.exists(\"storage\")&&$file.move({src:\"storage\",dst:t}),this.compatibility.deleteFiles([\"storage\"])}ver11(){this.kernel.storage.beginTransaction();try{[\"create table temp as select uuid, text, prev, next from clips where 1=1;\",\"drop table clips;\",\"alter table temp rename to clips;\",\"create table temp as select uuid, text, prev, next from favorite where 1=1;\",\"drop table favorite;\",\"alter table temp rename to favorite;\"].forEach(t=>this.kernel.storage.sqlite.update(t)),this.kernel.storage.commit()}catch(t){throw this.kernel.storage.rollback(),this.kernel.logger.error(t),t}}ver12(){i&&this.compatibility.deleteFiles([\"shared://caio\",\"storage\"])}ver13(){this.compatibility.deleteFiles([\"setting.json\",\"dist/CAIO-en.json\",\"dist/CAIO-zh-Hans.json\",\"dist/CAIO.js\",\"assets/icon\"])}}async function a(t){if(t)try{new n(t).do()}catch(e){throw t.logger.error(e),e}}t.exports=a}),a(\"iuWEe\",function(t,e){let i;var s=n(\"gxpqj\"),a=s.Kernel,r=s.UIKit,o=n(\"2aNLD\"),l=o.KeyboardAddins,h=o.KeyboardPinActions,c=n(\"23NnO\"),d=n(\"ilpYs\").TodayPinActions;t.exports=function(t){(i=t).setting.method.checkUpdate=async t=>{let e;t.start();let s=\"scripts/libs/easy-jsbox.js\";if($file.exists(s))try{let t=await i.checkUpdate();t&&($file.write({data:$data({string:t}),path:s}),$ui.toast(\"The framework has been updated.\"))}catch{}let n=await $http.get({url:\"https://raw.githubusercontent.com/ipuppet/CAIO/master/config.json\"}),r=n.data?.info.version;try{e=__INFO__}catch{e=JSON.parse($file.read(\"config.json\").string).info}a.versionCompare(r,e.version)>0?$ui.alert({title:\"New Version\",message:`New version found: ${r}\nUpdate via Github or click the button to open Erots.`,actions:[{title:$l10n(\"CANCEL\")},{title:\"Erots\",handler:()=>{$addin.run({name:\"Erots\",query:{q:\"show\",objectId:\"603e6eaaca0dd64fcef93e2d\"}})}}]}):$ui.toast(\"No need to update\"),t.done()},i.setting.method.previewWidget=()=>{let t={};try{JSON.parse($file.read(\"widget-options.json\").string).forEach(e=>{t[e.name]=e.value})}catch(t){$ui.error(t);return}$ui.menu({items:Object.keys(t),handler:e=>{let{Widget:i}=n(\"gD12U\");i.render(t[e])}})},i.setting.method.fileManager=()=>{i.fileManager.push(i.fileStorage.basePath)},function(){i.setting.method.exportClipboard=t=>{t.start(),i.storage.export(e=>{e?t.done():t.cancel()})},i.setting.method.importClipboard=t=>{t.start(),$ui.alert({title:$l10n(\"ALERT_INFO\"),message:$l10n(\"OVERWRITE_ALERT\"),actions:[{title:$l10n(\"OK\"),handler:()=>{$drive.open({handler:e=>{if(void 0===e){t.cancel();return}\"db\"===e.fileName.slice(-2)||\"zip\"===e.fileName.slice(-3)?i.storage.import(e).then(()=>{t.done(),$delay(.3,()=>{$addin.restart()})}).catch(e=>{$ui.error(e),i.logger.error(e),t.cancel()}):($ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel())}})}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},i.setting.method.rebuildDatabase=t=>{t.start();let e=()=>{try{i.storage.rebuild(),t.done(),$delay(.8,()=>$addin.restart())}catch(e){t.cancel(),$ui.alert(e)}};$ui.alert({title:$l10n(\"REBUILD_DATABASE_ALERT\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{e()}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})},i.setting.method.deleteAllData=t=>{t.start(),$ui.alert({title:$l10n(\"DELETE_ALL_DATA_ALERT\"),actions:[{title:$l10n(\"DELETE\"),style:$alertActionType.destructive,handler:()=>{i.storage.deleteAllData(),t.done(),$delay(.5,()=>$addin.restart())}},{title:$l10n(\"CANCEL\"),handler:()=>{t.cancel()}}]})};let t=$text.uuid,e=()=>i.clips.getRecycleBin().map(t=>t?.text??\"None\");i.setting.method.recycleBin=()=>({type:\"list\",props:{id:t,data:e(),actions:[{title:\"delete\",handler:(t,e)=>{i.clips.removeFromRecycleBin(e.row)}}]},events:{didSelect:(t,e)=>{let s=i.clips.getRecycleBin()[e.row]??{};if(s.text){let n=i.clips.addItem(s.text);s.tag&&i.storage.setTag(n.uuid,s.tag),i.clips.removeFromRecycleBin(e.row),i.clips.updateList(!0),t.delete(e)}}},layout:$layout.fill}),i.setting.method.recycleBinNavButtons=()=>[{symbol:\"trash\",tapped:()=>{r.deleteConfirm($l10n(\"DELETE_TABLE\").replace(\"${table}\",$l10n(\"RECYCLE_BIN\")),()=>{i.clips.clearRecycleBin(),$(t).data=e()})}}]}(),i.setting.method.exportAction=t=>{t.start();let e=\"actions.zip\",s=`/${e}`,n=i.fileStorage.filePath(s);$archiver.zip({directory:i.actions.userActionPath,dest:n,handler:()=>{$share.sheet({items:[{name:e,data:$data({path:n})}],handler:e=>{e?t.done():t.cancel(),i.fileStorage.delete(s)}})}})},i.setting.method.importAction=t=>{t.start(),$drive.open({handler:e=>{if(void 0===e){t.cancel();return}if(\"zip\"===e.fileName.slice(-3)){let s=`${i.fileStorage.basePath}/action_import`;$archiver.unzip({file:e,dest:s,handler:()=>{$file.list(s).forEach(t=>{$file.isDirectory(`${s}/${t}`)&&$file.copy({src:`${s}/${t}`,dst:`${i.actions.userActionPath}/${t}`})}),$file.delete(s),t.done()}})}else $ui.warning($l10n(\"FILE_TYPE_ERROR\")),t.cancel()}})},i.setting.method.importExampleAction=t=>{t.start(),i.actions.importExampleAction(),t.done()},i.setting.method.rebuildAction=t=>{t.start(),$ui.alert({title:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_TITLE\"),message:$l10n(\"REBUILD_ACTION_DATABASE_ALERT_MESSAGE\"),actions:[{title:$l10n(\"REBUILD\"),style:$alertActionType.destructive,handler:()=>{$file.delete(i.actions.userActionPath),i.actions.setNeedReload(),t.done(),$delay(.8,()=>$addin.restart())}},{title:$l10n(\"CANCEL\"),handler:()=>t.cancel()}]})},i.setting.method.editCategory=()=>c.sheet(i),function(){let t=n(\"7eNYp\");i.setting.method.previewKeyboard=()=>{let e=new t(i),s=t=>{e.setKeyboardHeight(t),$(e.keyboardId).updateLayout(t=>{t.height.equalTo(e.keyboardHeight)}),1===e.keyboardDisplayMode&&$(e.keyboardId).get(e.views.listId).reload()},n=t=>(t-200)/200;return{views:[{type:\"label\",layout:(t,e)=>{t.top.inset(20),t.centerX.equalTo(e.super)},events:{ready:t=>t.text=e.keyboardHeight,tapped:t=>{$input.text({type:$kbType.number,text:e.keyboardHeight,handler:e=>{if(/^[0-9]+$/.test(e)){let i=Number(e);i=Math.max(i=Math.min(i,400),200),t.text=i,t.next.value=n(i),s(i)}else $ui.toast(\"Only integers can be entered.\")}})}}},{type:\"slider\",props:{max:1,min:0},layout:(t,e)=>{t.top.equalTo(e.prev.bottom),t.right.inset(20),t.width.equalTo(e.super).offset(-40)},events:{ready:t=>t.value=n(e.keyboardHeight),changed:t=>{let e=Math.floor(200*t.value+200);t.prev.text=e,s(e)}}},e.getView()],layout:(t,e)=>{t.left.right.bottom.equalTo(e.super.safeArea);let s=0;1===i.setting.get(\"mainUIDisplayMode\")&&(s=r.NavigationBarNormalHeight),t.top.equalTo(e.super.safeArea).inset(s)}}},i.setting.method.setKeyboardQuickStart=()=>{new l().sheet()},i.setting.method.keyboardPinAction=()=>{h.shared.setKernel(i).sheet()}}(),i.setting.method.previewTodayWidget=t=>{let e=new(n(\"49je6\"))(i).getView();r.push({views:[e]})},i.setting.method.setTodayWidgetActions=t=>{d.shared.setKernel(i).sheet()}}}),a(\"23NnO\",function(t,e){var i=n(\"gxpqj\").Sheet;class s{constructor(t){this.kernel=t,this.listId=\"action-category-list\"}getNavButtons(){return[{symbol:\"plus\",tapped:()=>this.kernel.actions.addActionCategory()}]}getActionCategories(){let t=this.kernel.actions.defaultCategories();return this.kernel.actions.getActionCategories().filter(e=>0>t.indexOf(e))}getListView(){return{type:\"list\",props:{id:this.listId,reorder:!1,data:this.getActionCategories(),actions:[{title:\" \"+$l10n(\"DELETE\")+\" \",color:$color(\"red\"),handler:async(t,e)=>{await this.kernel.actions.deleteActionCategory(t.object(e))&&t.delete(e)}}]},events:{didSelect:async(t,e,i)=>{await this.kernel.actions.renameActionCategory(i)&&(t.data=this.getActionCategories())}},layout:$layout.fill}}static async sheet(t){let e=new i,n=new s(t);e.setView(n.getListView()).addNavBar({title:$l10n(\"EDIT_CATEGORY\"),popButton:{title:$l10n(\"DONE\")},rightButtons:n.getNavButtons()}),e.init().present()}}t.exports=s}),a(\"7eNYp\",function(t,e){var i=n(\"eSp9Z\"),s=i.ActionData,a=i.ActionEnv,r=n(\"gxpqj\"),o=r.UIKit,l=r.Sheet,h=r.BarButtonItem,c=n(\"4c0o0\"),d=n(\"2aNLD\"),u=d.KeyboardAddins,p=d.KeyboardPinActions;class g extends c{static ReturnKeyType={UIReturnKeyDefault:0,UIReturnKeyGo:1,UIReturnKeyGoogle:2,UIReturnKeyJoin:3,UIReturnKeyNext:4,UIReturnKeyRoute:5,UIReturnKeySearch:6,UIReturnKeySend:7,UIReturnKeyYahoo:8,UIReturnKeyDone:9,UIReturnKeyEmergencyCall:10,UIReturnKeyContinue:11,UIReturnKeyJoining:12,UIReturnKeyRouteContinue:13};#N;keyboardId=\"keyboard.main\";actionsId=\"keyboard-list-actions\";keyboardSwitchLockId=\"keyboard-switch-lock\";keyboardSwitchLockKey=\"caio.keyboard.switch.lock\";keyboardReturnButton=\"keyboard-return-button\";deleteTimer=void 0;continuousDeleteTimer=void 0;continuousDeleteTapticTimer=void 0;continuousDeleteDelay=.5;navHeight=50;keyboardFrameHeight=this.keyboardHeight;get isFullScreenIpad(){return!!$device.isIpad&&(this.isFullScreenIpadCacheTimer?.cancel(),this.isFullScreenIpadCacheTimer=$delay(.1,()=>{$cache.get(\"keyboard.isFullScreenIpad\")!==!o.isSplitScreenMode&&this.kernel.KeyboardRenderWithViewFunc(()=>this.getView()),$cache.set(\"keyboard.isFullScreenIpad\",!o.isSplitScreenMode)}),$cache.get(\"keyboard.isFullScreenIpad\")??!o.isSplitScreenMode)}get bottomBarHeight(){return this.isFullScreenIpad?90:50}get bottomButtonSize(){return $device.isIpad?this.isFullScreenIpad?{width:69,height:66}:{width:32,height:40}:{width:46,height:40}}get bottomButtonFontSize(){return this.isFullScreenIpad?20:16}get bottomButtonIconSize(){return this.isFullScreenIpad?26:16}get bottomButtonEdges(){return this.isFullScreenIpad?8:4}itemBackground=$color(\"#FFFFFF\",$rgba(151,151,151,.4));buttonBackground=$color($rgba(0,0,0,.15),$rgba(117,117,117,.4));constructor(t){super(t),this.keyboardDisplayMode=this.kernel.setting.get(\"keyboard.displayMode\"),this.backgroundImage=this.kernel.setting.get(\"keyboard.background.image\")?.image,this.useBlur=this.backgroundImage&&this.kernel.setting.get(\"keyboard.blur\"),this.deleteDelay=this.kernel.setting.get(\"keyboard.deleteDelay\"),\"boolean\"!=typeof $cache.get(this.keyboardSwitchLockKey)&&$cache.set(this.keyboardSwitchLockKey,!1),this.views.listId+=\"keyboard\",this.views.scrollToOffsetDirectionX=this.keyboardDisplayMode,this.views.tabLeftMargin=10,this.views.horizontalMargin=15,this.views.verticalMargin=12,this.views.copiedIndicatorSize=5,this.views.containerMargin=this.isFullScreenIpad?12:4,this.views.fontSize=this.kernel.setting.get(\"keyboard.fontSize\"),this.views.tagHeight=this.views.verticalMargin+3,this.delegates.menuItemActionMaxCount=3,this.matrixBoxMargin=this.isFullScreenIpad?12:8,this.cornerRadius=this.isFullScreenIpad?8:5}get returnKeyLabel(){let t;switch($ui.controller.ocValue().$textDocumentProxy().$returnKeyType()){case g.ReturnKeyType.UIReturnKeyDefault:t=\"Return\";break;case g.ReturnKeyType.UIReturnKeyGo:t=\"Go\";break;case g.ReturnKeyType.UIReturnKeyGoogle:t=\"Google\";break;case g.ReturnKeyType.UIReturnKeyJoin:t=\"Join\";break;case g.ReturnKeyType.UIReturnKeyNext:t=\"Next\";break;case g.ReturnKeyType.UIReturnKeyRoute:t=\"Route\";break;case g.ReturnKeyType.UIReturnKeySearch:t=\"Search\";break;case g.ReturnKeyType.UIReturnKeySend:t=\"Send\";break;case g.ReturnKeyType.UIReturnKeyYahoo:t=\"Yahoo\";break;case g.ReturnKeyType.UIReturnKeyDone:t=\"Done\";break;case g.ReturnKeyType.UIReturnKeyEmergencyCall:t=\"Emergency Call\";break;case g.ReturnKeyType.UIReturnKeyContinue:t=\"Continue\";break;case g.ReturnKeyType.UIReturnKeyJoining:t=\"Joining\";break;case g.ReturnKeyType.UIReturnKeyRouteContinue:t=\"Route Continue\";break;default:t=\"Return\"}return $cache.set(\"keyboard.returnKeyLabel\",$l10n(t)),$l10n(t)}get returnKeyLabelCache(){return $cache.get(\"keyboard.returnKeyLabel\")??this.returnKeyLabel}get keyboardHeight(){return this.kernel.setting.get(\"keyboard.previewAndHeight\")}get menu(){let t=this.delegates.menu.items;return{items:[t[0],t[2]]}}setKeyboardHeight(t){this.kernel.setting.set(\"keyboard.previewAndHeight\",t)}getKeyboardSwitchLock(){let t=$cache.get(this.keyboardSwitchLockKey);return\"boolean\"!=typeof t&&$cache.set(this.keyboardSwitchLockKey,!0),t}switchKeyboardSwitchLock(){let t=$cache.get(this.keyboardSwitchLockKey);$cache.set(this.keyboardSwitchLockKey,!t),$(this.keyboardSwitchLockId).get(\"image\").symbol=t?\"lock.open\":\"lock\"}listReady(){if(0===this.keyboardDisplayMode)this.setDelegate();else{let t=$delegate({type:\"UICollectionViewDragDelegate\",events:{\"collectionView:itemsForBeginningDragSession:atIndexPath:\":(t,e,i)=>this.delegates.itemsForBeginningDragSession(e,i)}});$(this.views.listId).ocValue().$setDragDelegate(t)}this.updateList(),this.kernel.setting.get(\"clipboard.autoSave\")&&$app.env===$env.keyboard&&(this.readClipboard(),this.#N=$timer.schedule({interval:1,handler:()=>{if(!this.kernel.setting.get(\"clipboard.autoSave\")){this.#N.invalidate();return}this.readClipboard()}}))}keyboardTapped(t,e=!0){return async(...i)=>{if(e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.kernel.setting.get(\"keyboard.tapticEngineLevel\")),\"function\"==typeof t)try{await t(...i)}catch(t){throw this.kernel.logger.error(t),t}}}async getKeyboardActionData(){let t=$keyboard.selectedText;\"\"===t&&(t=null);let e=async()=>{let t=await $keyboard.getAllText();return\"\"===t&&(t=null),t};return new s({env:a.keyboard,textBeforeInput:$keyboard.textBeforeInput,textAfterInput:$keyboard.textAfterInput,text:t??await e(),allText:await $keyboard.getAllText(),selectedText:t})}getTopButtonsView(){let t=[{symbol:\"keyboard.chevron.compact.down\",tapped:this.keyboardTapped(()=>$keyboard.dismiss())},{symbol:\"square.and.arrow.down.on.square\",tapped:this.keyboardTapped(async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}})}];return t.push({symbol:\"bolt.circle\",tapped:this.keyboardTapped(()=>{let t=!0===$(this.actionsId).hidden;$(this.views.listId).hidden=t,$(this.actionsId).hidden=!t})}),p.shared.setKernel(this.kernel).getActions().forEach(e=>{let i=e?.icon?.slice(0,5)===\"icon_\"?$icon(e.icon.slice(5,e.icon.indexOf(\".\")),o.textColor):$image(e?.icon);t.push({symbol:i,tapped:this.keyboardTapped(async()=>{let t=await this.getKeyboardActionData();this.kernel.actions.getActionHandler(e.category,e.dir)(t)})})}),{type:\"view\",views:t.map(t=>{let e=new h;return e.buttonEdges=0,e.setAlign(o.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).definition}),layout:(e,i)=>{let s=new h;e.height.equalTo(i.super),e.right.inset(-s.edges),e.width.equalTo(s.width*t.length+s.edges)}}}getTopBarView(){return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[{type:\"image\",props:{image:$image(\"assets/icon.png\",\"assets/icon.white.png\")},events:{tapped:()=>this.kernel.openInJsbox(),ready:t=>{$cache.get(\"tips.keyboard.title\")||($cache.set(\"tips.keyboard.title\",!0),$ui.popover({sourceView:t,size:$size(200,60),directions:$popoverDirection.up,views:[{type:\"label\",props:{lines:0,text:$l10n(\"CLICK_TO_OPEN_JSBOX\"),align:$align.center},layout:$layout.fillSafeArea}]}))}},layout:(t,e)=>{t.centerY.equalTo(e.super),t.left.inset(-2),t.size.equalTo($size(28,28))}}].concat(super.getTabView(),this.getTopButtonsView())}],layout:(t,e)=>{t.top.equalTo(e.super),t.left.equalTo(e.super.safeArea).offset(this.views.containerMargin),t.right.equalTo(e.super.safeArea).offset(-this.views.containerMargin),t.height.equalTo(this.navHeight)}}}#P(t,e){let i=this.bottomButtonSize,s=this.bottomButtonEdges,n=this.isFullScreenIpad?8:5,a=(n,a)=>{if(t.title){let e=Math.ceil($text.sizeThatFits({text:t.title,width:o.windowSize.width,font:$font(this.bottomButtonFontSize)}).width)+(s+12)*2;this.isFullScreenIpad&&(e=Math.max(1.5*i.height,e)),n.size.equalTo($size(e,i.height))}else n.size.equalTo(i);n.centerY.equalTo(a.super),a.prev&&a.prev.info.align===e?e===o.align.right?n.right.equalTo(a.prev.left).offset(-(1.5*s)):n.left.equalTo(a.prev.right).offset(1.5*s):e===o.align.right?n.right.inset(0):n.left.inset(0)},r={type:\"button\",props:Object.assign({smoothCorners:!1,cornerRadius:this.cornerRadius,id:t.id??$text.uuid,bgcolor:this.useBlur?$color(\"clear\"):this.buttonBackground,info:{align:e}},t.menu?{menu:t.menu}:{}),views:[{type:\"image\",props:{symbol:t.symbol,tintColor:o.textColor},layout:(t,i)=>{t.size.greaterThanOrEqualTo(this.bottomButtonIconSize),this.isFullScreenIpad?(t.bottom.inset(n),e===o.align.right?t.right.inset(n):t.left.inset(n)):t.center.equalTo(i.super)}},{type:\"label\",props:{text:t.title,font:$font(this.bottomButtonFontSize),color:o.textColor},layout:(t,i)=>{this.isFullScreenIpad?(t.bottom.inset(n),e===o.align.right?t.right.inset(n):t.left.inset(n)):t.center.equalTo(i.super)}}],events:Object.assign({},t.tapped?{tapped:t.tapped}:{},t.events),layout:$layout.fill};return this.useBlur?o.blurBox({info:{align:e},style:$blurStyle.ultraThinMaterial,smoothCorners:!1,cornerRadius:this.cornerRadius},[r],a):{type:\"view\",props:{info:{align:e}},views:[r],layout:a}}getBottomButtonsView(){let t=[],e=[];$ui.controller.ocValue().$needsInputModeSwitchKey()&&t.push({symbol:\"globe\",events:{ready:t=>{t.ocValue().$addTarget_action_forControlEvents($ui.controller.ocValue(),\"handleInputModeListFromView:withEvent:\",$UIEvent.allTouchEvents)}}}),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&t.push({symbol:this.getKeyboardSwitchLock()?\"lock\":\"lock.open\",id:this.keyboardSwitchLockId,tapped:this.keyboardTapped(()=>this.switchKeyboardSwitchLock())}),t.push({symbol:\"paperplane\",menu:{pullDown:!0,asPrimary:!0,items:u.getAddins().reverse().map(t=>({title:t,handler:this.keyboardTapped(()=>$addin.run(t))}))}}),e.push({title:this.returnKeyLabelCache,id:this.keyboardReturnButton,tapped:this.keyboardTapped(()=>$keyboard.send()),events:{ready:async()=>{await $wait(.2);let t=this.returnKeyLabel,e=this.#P({title:t},o.align.right).layout;$ui.animate({duration:.2,animation:()=>{$(this.keyboardReturnButton).super.updateLayout(e),$(this.keyboardReturnButton).super.relayout()},completion:()=>{$(this.keyboardReturnButton).get(\"label\").text=t}})}}},{symbol:\"delete.left\",events:{touchesBegan:this.keyboardTapped(async()=>{$keyboard.delete(),this.continuousDeleteTapticTimer=$delay(this.continuousDeleteDelay,()=>this.keyboardTapped()()),this.continuousDeleteTimer=$delay(this.continuousDeleteDelay,()=>{this.deleteTimer=$timer.schedule({interval:this.deleteDelay,handler:()=>$keyboard.delete()})})}),touchesEnded:()=>{this.deleteTimer?.invalidate(),this.continuousDeleteTimer?.cancel(),this.continuousDeleteTapticTimer?.cancel(),this.deleteTimer=void 0,this.continuousDeleteTimer=void 0}}});let i={type:\"button\",props:{smoothCorners:!1,cornerRadius:5,title:$l10n(\"SPACE\"),font:$font(16),bgcolor:this.itemBackground,titleColor:o.textColor},events:{tapped:this.keyboardTapped(()=>{$keyboard.insert(\" \")})},layout:(t,i)=>{let s=i.prev;for(let t=0;tthis.#P(t,o.align.left)),...e.map(t=>this.#P(t,o.align.right)),i]}getBottomBarView(){return{type:\"view\",views:this.getBottomButtonsView(),layout:(t,e)=>{t.bottom.equalTo(e.super.safeArea),t.left.equalTo(e.super.safeArea).offset(this.views.containerMargin),t.right.equalTo(e.super.safeArea).offset(-this.views.containerMargin),t.height.equalTo(this.bottomBarHeight)}}}itemContainer(t){return this.useBlur?o.blurBox({style:$blurStyle.ultraThinMaterial},t,$layout.fill):{type:\"view\",props:{bgcolor:this.itemBackground},views:t,layout:$layout.fill}}get matrixTemplate(){return{props:{smoothCorners:!0,cornerRadius:10},views:[this.itemContainer([{type:\"view\",props:{id:\"copied\",circular:this.views.copiedIndicatorSize,hidden:!0,bgcolor:$color(\"green\")},layout:(t,e)=>{t.size.equalTo(this.views.copiedIndicatorSize),t.left.top.inset(this.matrixBoxMargin/2)}},{type:\"label\",props:{id:\"content\",lines:0,font:$font(this.views.fontSize)},layout:(t,e)=>{t.top.left.right.equalTo(e.super).inset(this.matrixBoxMargin),t.height.lessThanOrEqualTo(e.super).offset(-(2*this.matrixBoxMargin)-this.views.tagHeight)}},{type:\"label\",props:{id:\"tag\",lines:1,color:this.tagColor,autoFontSize:!0,align:$align.leading},layout:(t,e)=>{t.left.right.equalTo(e.prev),t.height.equalTo(this.views.tagHeight),t.bottom.equalTo(e.super).inset(this.matrixBoxMargin)}}]),{type:\"image\",props:{id:\"image\",hidden:!0},layout:$layout.fill}]}}get itemSelect(){return(t,e)=>{let i=this.clips[e.row];i.image?l.quickLookImage(i.imageOriginal):($keyboard.insert(i.text),this.kernel.setting.get(\"keyboard.switchAfterInsert\")&&!this.getKeyboardSwitchLock()&&$keyboard.next())}}getMatrixView(){return{type:\"matrix\",props:{id:this.views.listId,bgcolor:$color(\"clear\"),menu:this.delegates.menu,direction:$scrollDirection.horizontal,alwaysBounceVertical:!1,alwaysBounceHorizontal:!0,showsHorizontalIndicator:!1,columns:1,spacing:this.matrixBoxMargin,template:this.matrixTemplate,backgroundView:$ui.create(this.views.getEmptyBackground())},layout:(t,e)=>{t.top.inset(0),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-1*(this.bottomBarHeight-this.navHeight))},events:{ready:()=>this.listReady(),didSelect:this.itemSelect,itemSize:(t,e)=>{let i=this.keyboardFrameHeight-this.navHeight-this.bottomBarHeight;return i-=2*this.matrixBoxMargin,this.itemSize[e.item]=i,$size(i,i)},layoutSubviews:t=>{let e=2*(this.navHeight+this.bottomBarHeight+this.matrixBoxMargin)-this.matrixBoxMargin+1,i=Math.max(t.frame.height,e);this.keyboardFrameHeight!==i&&(this.keyboardFrameHeight=i,t.reload())}}}}getListView(){let t=super.getListView();t.layout=(t,e)=>{t.top.equalTo(this.navHeight-1),t.width.equalTo(e.super),t.bottom.equalTo(e.super.safeAreaBottom).offset(-this.bottomBarHeight-this.views.containerMargin)},this.delegates.didSelectRowAtIndexPath=(t,e)=>{t=t.jsValue(),e=e.jsValue(),this.itemSelect(t,e)},this.delegates.shouldBeginMultipleSelectionInteractionAtIndexPath=()=>!1,t.props.separatorColor=$color(\"lightGray\"),t.props.separatorInset=$insets(0,this.views.horizontalMargin,0,this.views.horizontalMargin),delete t.events.pulled,t.props.header={props:{height:1}},t.props.style=2;let e=t.props.template.views[0].views;return t.props.template.views[0]=this.itemContainer(e),t}getDataView(){return 0===this.keyboardDisplayMode?this.getListView():this.getMatrixView()}getActionView(){return{type:\"view\",props:{id:this.actionsId,hidden:!0},views:[this.kernel.actions.views.getActionMiniView(async()=>await this.getKeyboardActionData())],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.equalTo(this.views.containerMargin),t.right.equalTo(-this.views.containerMargin),t.bottom.equalTo(-this.bottomBarHeight)}}}getView(){let t={type:\"view\",views:[{type:\"image\",props:{image:this.backgroundImage},layout:$layout.fill},{type:\"view\",props:{bgcolor:$color(\"clear\",$rgba(0,0,0,.3))},layout:$layout.fill}],layout:$layout.fill};return{type:\"view\",props:{id:this.keyboardId},views:[this.backgroundImage?t:{},this.getDataView(),this.getTopBarView(),this.getBottomBarView(),this.getActionView()],layout:(t,e)=>{t.width.bottom.equalTo(e.super),t.height.equalTo(this.keyboardHeight)}}}}t.exports=g}),a(\"49je6\",function(t,e){var i=n(\"eSp9Z\"),s=i.ActionData,a=i.ActionEnv,r=n(\"gxpqj\"),o=r.View,l=r.UIKit,h=r.BarButtonItem,c=n(\"4c0o0\"),d=n(\"ilpYs\").TodayPinActions;class u extends c{actionsId=\"today-list-actions\";listContainerId=\"today-list-container\";readClipboardButtonId=\"today-nav-readClipboard\";pageIndexId=\"today-list-page-index\";navHeight=34;taptic=1;inLauncher=$app.env===$env.today&&-1===$app.widgetIndex;launcherNavHeight=44;constructor(t){super(t),this.tabItems.push($l10n(\"ACTIONS\")),this.todayPinActions=new d(this.kernel),this.setClipboarPageSize($widget.mode),this.listPageNow=[0,0],this.listSection=Math.min(this.tabIndex,1),this.views.listId+=\"today\",this.views.tabLeftMargin=8,this.views.horizontalMargin=15,this.views.verticalMargin=5,this.views.copiedIndicatorSize=5,this.views.fontSize=14,this.views.tagHeight=12,this.views.tagColor=$color(\"gray\",\"lightGray\"),this.views.setSingleLine()}get isActionPage(){return 2===this.tabIndex}set tabIndex(t){$cache.set(\"caio.today.tab.index\",t)}get tabIndex(){return $cache.get(\"caio.today.tab.index\")??0}get menu(){let t=this.delegates.defaultMenuItems.reverse();return t[0].items=t[0].items.reverse(),{items:t}}getByIndex(t){\"object\"==typeof t&&(t=t.row);let e=this.listPageSize*this.listPageNow[this.listSection];return t+=e,this.clips[t]}listReady(){$widget.modeChanged=t=>{this.setClipboarPageSize(t),this.isActionPage||this.updateList()},this.setClipboarPageSize($widget.mode),this.isActionPage||this.updateList(),this.appListen(),$delay(.5,()=>this.readClipboard())}async readClipboard(t=!1){this.isActionPage||$app.env!==$env.today||await super.readClipboard(t)}setClipboarPageSize(t){if(0===t)this.listPageSize=1;else{let t=(($app.env===$env.app?l.windowSize.height:$widget.height)-2*this.navHeight-(this.inLauncher?this.launcherNavHeight:0))/(this.views.singleLineContentHeight+this.views.verticalMargin+Math.max(this.views.tagHeight,this.views.verticalMargin)),e=Math.floor(t);this.listPageSize=e,t-e>=.6&&this.listPageSize++}}buttonTapped(t,e=!0){return async(...i)=>{e&&this.kernel.setting.get(\"keyboard.tapticEngine\")&&$device.taptic(this.taptic),await t(...i)}}switchTab(t){this.tabIndex=t,this.isActionPage?($(this.listContainerId).hidden=!0,$(this.actionsId).hidden=!1,$(this.readClipboardButtonId).hidden=!0):(this.listSection=t,$(this.actionsId).hidden=!0,$(this.listContainerId).hidden=!1,$(this.readClipboardButtonId).hidden=!1,this.updateList())}getNavBarView(){let t=[{symbol:\"square.and.arrow.down.on.square\",props:{id:this.readClipboardButtonId,hidden:this.isActionPage},tapped:this.buttonTapped(async t=>{t.start();try{await this.readClipboard(!0),t.done()}catch(e){throw t.cancel(),e}})}].map(t=>{let e=new h;return e.setAlign(l.align.right).setSymbol(t.symbol).setEvent(\"tapped\",t.tapped).setProps(t.props??{}),e.definition});return{type:\"view\",views:[{type:\"view\",layout:$layout.fill,views:[this.getTabView(),...t]}],layout:(t,e)=>{t.top.width.equalTo(e.super),t.height.equalTo(this.navHeight)}}}getBottomBarView(){let t=t=>({type:\"button\",props:{symbol:t===l.align.left?\"chevron.backward.circle\":\"chevron.forward.circle\",bgcolor:$color(\"clear\"),tintColor:l.textColor},layout:i=>{t===l.align.left?i.left.inset(this.views.horizontalMargin):i.right.inset(this.views.horizontalMargin),i.centerY.equalTo(e.super)},events:{tapped:this.buttonTapped(()=>{t===l.align.left?this.clipboardPrevPage():this.clipboardNextPage()})}}),e={type:\"view\",views:[t(l.align.left),t(l.align.right),{type:\"label\",props:{id:this.pageIndexId,align:$align.center,text:this.listPageNow[this.listSection]+1},layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.center.equalTo(e.super)}}],layout:(t,e)=>{t.bottom.left.right.equalTo(e.super.safeArea),t.height.equalTo(this.navHeight)}};return e}delete(...t){super.delete(...t),this.updateList()}updateList(t=!1){t&&this.setNeedReload();let e=this.listPageNow[this.listSection]*this.listPageSize,i=e+this.listPageSize,s=this.clips;$(this.views.listId).data=s.slice(e,i).map(t=>this.views.lineData(t,this.copied.uuid===t.uuid));let n=this.listPageNow[this.listSection]+1,a=Math.ceil(s.length/this.listPageSize);$(this.pageIndexId).text=`${n}/${a}`}clipboardPrevPage(){this.listPageNow[this.listSection]>0&&(this.listPageNow[this.listSection]--,this.updateList())}clipboardNextPage(){let t=Math.ceil(this.clips.length/this.listPageSize);this.listPageNow[this.listSection]this.listReady(),rowHeight:(t,e)=>{let i=this.getByIndex(e),s=i.hasTag?this.views.tagHeight:this.views.verticalMargin,n=i.image?this.views.imageContentHeight:this.views.getContentHeight(i.text);return this.views.verticalMargin+n+s},didSelect:this.buttonTapped((t,e)=>{let i=this.getByIndex(e);i.image?$clipboard.image=i.imageOriginal:(this.setClipboardText(i.text),this.setCopied(i.uuid)),$ui.toast($l10n(\"COPIED\"))})},layout:(t,e)=>{t.top.width.equalTo(e.super),t.bottom.equalTo(e.super).offset(-this.navHeight)}},this.getBottomBarView()],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.bottom.left.right.equalTo(e.super.safeArea)}}}getActionView(){let t=this.todayPinActions.getActions();return 0===t.length&&(t=Object.values(this.kernel.actions.allActions)),{type:\"view\",props:{id:this.actionsId,hidden:!this.isActionPage},views:[this.kernel.actions.views.getActionMiniView(t=>new s({env:a.today,text:\"clipboard\"===t.category||\"uncategorized\"===t.category?$clipboard.text:null}),t)],layout:(t,e)=>{t.top.equalTo(this.navHeight),t.left.right.bottom.equalTo(e.super.safeArea)}}}getView(){return o.create({props:{titleColor:l.textColor,barColor:l.primaryViewBackgroundColor},views:[{type:\"view\",views:[this.getNavBarView(),this.getActionView(),this.getListView()],layout:$layout.fill}],events:{appeared:async()=>{if($app.env!==$env.today)return;let t=$timer.schedule({interval:0,handler:()=>{$ui.animate({duration:.3,animation:()=>{$ui.vc.ocValue().$view().$setBackgroundColor($color(\"clear\"))},completion:()=>{t.invalidate()}})}})}}})}}t.exports=u}),a(\"gD12U\",function(t,e){var i=n(\"8Makm\").AppKernelBase;class s extends i{logFile=\"widget.log\";constructor(){super(),this.setting.setReadonly()}get isWebdavEnabled(){return!1}}class a{static kernel=new s;static widgetInstance(t,...e){if(!$file.exists(`/scripts/widget/${t}.js`))return!1;{let{Widget:i}=require(`./widget/${t}.js`);return new i(...e)}}static renderError(){$widget.setTimeline({render:()=>({type:\"text\",props:{text:\"Invalid argument\"}})})}static renderClips(){a.widgetInstance(\"Clips\",a.kernel).render()}static renderFavorite(){a.widgetInstance(\"Favorite\",a.kernel).render()}static renderActions(){a.widgetInstance(\"Actions\",a.kernel).render()}static render(t=$widget.inputValue??\"Actions\"){switch(t){case\"Clips\":a.renderClips();break;case\"Favorite\":a.renderFavorite();break;case\"Actions\":a.renderActions();break;default:a.renderError()}}}t.exports={Widget:a,run:()=>{a.render()}}}),a(\"ljE8b\",function(t,e){var i=n(\"8Makm\").AppKernelBase;class s extends i{constructor(){super(),this.setting.setReadonly()}addOpenInJsboxButton(){this.useJsboxNav(),this.setNavButtons([{image:$image(\"assets/icon.png\"),handler:()=>this.openInJsbox()}])}}class a{static kernel=new s;static renderKeyboardUI(){this.kernel.addOpenInJsboxButton();let t=new(n(\"7eNYp\"))(this.kernel);this.kernel.KeyboardRenderWithViewFunc(()=>t.getView())}static renderTodayUI(){this.kernel.addOpenInJsboxButton();let t=new(n(\"49je6\"))(this.kernel);this.kernel.UIRender(t.getView())}static shortcuts(){let t=$context.query.table?.trim()??\"\";if(\"\"!==t){let e=this.kernel.clips.tabItemsMap;this.kernel.clips.rememberTabIndex=!1,this.kernel.clips.tabIndex=e[t]??e.clips}try{if(void 0!==$context.query.set){let t=$context.query.set;if(\"\"===t.trim())throw Error(\"cannot set empty content\");this.kernel.clips.addItem(t),$intents.finish()}else if(void 0!==$context.query.get){let t=$context.query.get??0;if(\"number\"!=typeof t)throw Error(\"`get` must be a number index\");let e=this.kernel.clips.getByIndex(t);$intents.finish(e.text)}else $intents.finish(\"`get` or `set` is required\")}catch(t){$intents.finish(t.message)}finally{$intents.finish()}}}t.exports={run:()=>{$app.env===$env.today?a.renderTodayUI():$app.env===$env.keyboard?a.renderKeyboardUI():$app.env===$env.siri&&a.shortcuts()}}}),$app.strings={en:{AUTHOR:\"Author\",ALERT_INFO:\"Alert\",NONE:\"Nothing\",DONE:\"Done\",CLOSE:\"Close\",FAILED_TO_LOAD_VIEW:\"Faild to load view\",VIEW_NOT_PROVIDED:\"The view is not provided\",UNCATEGORIZED:\"Uncategorized\",SHARE:\"Share\",CLICK_TO_OPEN_JSBOX:\"Click the title to open the main app.\",CLIPS:\"Clips\",CLIPBOARD:\"Clipboard\",UNIVERSAL_CLIPBOARD:\"Universal Clipboard\",UNIVERSAL_CLIPBOARD_TIPS:\"Universal Clipboard allows you to copy something on your iPhone, and paste it on your Mac–or vice-versa–using iCloud.\",CLIPS_STRUCTURE_ERROR:\"Clips data structure is abnormal\",CLIPBOARD_NO_CHANGE:\"Clipboard no change\",RECYCLE_BIN:\"Recycle Bin\",ADD:\"Add\",TAG:\"Tag\",ADD_TAG:\"Add Tag\",EDIT:\"Edit\",SEARCH:\"Search\",SEARCH_HISTORY:\"Search History\",SEARCH_RESULT:\"Search Result\",NO_SEARCH_RESULT:\"No item found.\",FAVORITE:\"Favorite\",COPY:\"Copy\",COPIED:\"Copied\",SORT:\"Sort\",ACTIONS:\"Actions\",MORE_ACTIONS:\"More Actions\",PREVIEW:\"Preview\",MAX_ITEM_LENGTH:\"Line Limit\",TEXT_MAX_LENGTH:\"Display Character Length\",AUTO_SAVE:\"Auto Save\",AUTO_SYNC:\"Auto Sync\",SYNC_NOW:\"Sync Now\",UNZIP_FAILED:\"Unzip file failed\",REBUILD:\"Rebuild\",REBUILD_DATABASE:\"Rebuild Database\",REBUILD_DATABASE_ALERT:\"Rebuilding the database will lose the order information, do you want to confirm the rebuild?\",DELETE_ALL_DATA:\"Delete All Data\",DELETE_ALL_DATA_ALERT:\"Are you sure you want to delete all your data?\",DELETE_DATA:\"Delete Data\",DELETE_TABLE:\"Delete all data from `${table}`?\",SELECT_ALL:\"Select All\",DESELECT_ALL:\"Deselect All\",EDITOR:\"Editor\",CREATE_NEW:\"Create New\",CREATE_NEW_ACTION:\"New Action\",CREATE_NEW_TYPE:\"New Category\",TYPE_ALREADY_EXISTS:\"This category already exists\",EDIT_DETAILS:\"Edit Details\",EDIT_SCRIPT:\"Edit Script\",INFORMATION:\"Information\",NAME:\"Name\",ICON:\"Icon\",CATEGORY:\"Category\",EDIT_CATEGORY:\"Edit Category\",\"delete.category\":\"Delete Category ${category}\",\"delete.category.keep.actions\":\"Do you keep the actions in this category?\",DESCRIPTION:\"Description\",CODE:\"Code\",TEXT_INSETS:\"Text bottom margin\",SHOW_LINE_NUMBER:\"Show line number\",LIGHT_MODE_THEME:\"Light Mode Theme\",DARK_MODE_THEME:\"Dark Mode Theme\",SAVE:\"Save\",SAVE_SUCCESS:\"Save success\",SAVE_ERROR:\"Save failed\",DELETE:\"Delete\",CONFIRM:\"Confirm\",DELETE_CONFIRM_MSG:\"Are you sure you want to delete?\",DELETE_SUCCESS:\"Delete success\",DELETE_ERROR:\"Delete failed\",IMPORT_EXAMPLE_ACTIONS:\"Import example actions\",REBUILD_ACTION_DATABASE:\"Rebuild Action Database\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"Are you sure you want to rebuild?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"Rebuild also deletes the data saved in WebDAV Drive! (If enabled)\",EXPORT:\"Export\",IMPORT:\"Import\",FILE_TYPE_ERROR:\"File type does not match\",OVERWRITE_ALERT:\"This operation will overwrite the current data. Do you want to continue?\",UNABLE_CREATE_ACTION:\"Unable to create action\",ACTION_NAME_ALREADY_EXISTS:\"Action `${name}` already exists\",IMPORT_FROM_FILE:\"Import from Files\",DEIT_CATEGORY:\"Edit Category\",KEYBOARD:\"Keyboard\",KEYBOARD_HEIGHT:\"Keyboard Height\",USE_BLUR:\"Use Blur\",BACKGROUND_IMAGE:\"Background Image\",DELETE_DELAY:\"Delete Delay\",SWITCH_AFTER_INSERT:\"Switch After Insert\",JSBOX_TOOLBAR:\"JSBox Toolbar\",QUICK_START_SCRIPTS:\"Quick Start Scripts\",SEND:\"Send\",OPEN_IN_JSBOX:\"Open in JSBox\",SWITCH_KEYBOARD:\"Switch Keyboard\",TAPTIC_ENGINE:\"Taptic Engine\",TAPTIC_ENGINE_LEVEL:\"Taptic Engine Level\",TAPTIC_ENGINE_FOR_DELETE:\"Taptic Engine For Delete\",SPACE:\"Space\",ALL_SCRIPTS:\"All Scripts\",SELECT_SCRIPTS:\"Select Scripts\",FONT_SIZE:\"Font Size\",LIST:\"List\",MATRIX:\"Matrix\",PIN_ACTION:\"Pin Action\",CHECK_UPDATE:\"Check Update\",UPDATE:\"Update\",WIDGET:\"Widget\",RECENT:\"Recent\",CLICK_ACTION:\"Click Action\",TODAY_WIDGET:\"Today Widget\",PREV_PAGE:\"Prev\",NEXT_PAGE:\"Next\",DISPLAY_MODE:\"Display Mode\",CLASSIC:\"Classic\",MODERN:\"Modern\",FILE_MANAGEMENT:\"File Management\",\"compatibility.rebuildUserAction.alert.title\":\"We need to rebuild some of the action!\",\"compatibility.rebuildUserAction.alert.message\":\"If you tap the OK button, the following actions will be rebuilt:\",\"compatibility.rebuildUserAction.alert.message2\":\"Only the action logic will be changed, and the name and icon will remain as it is.\",EXPERIMENTAL:\"Experimental\",SYNC_ACTIONS:\"Sync Actions\",SYNCING:\"Syncing...\",LAST_SYNC_AT:\"Last sync at: \",MODIFIED:\"Modified: \",WEBDAV_ERROR_CLOSED:\"WebDAV sync has an error and is temporarily closed.\",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"A data synchronization conflict occurred\",DATA_CONFLICT_MESSAGE:\"Select the data you want to keep\",WEBDAV_DATA:\"WebDAV data\",LOCAL_DATA:\"Local data\",ADD_TO_TAIO:\"Add to Taio\",SELECT_TAIO_APP:\"Please select Taio App from the Share menu.\",ACTION_SAFETY_WARNING:\"Action safety warning\",ACTION_PERMISSION_REQUEST:\"Action permission request\",ACTION_RESET_NAME_WARNING:\"Action `${name}` is attempting to change its name to `${to_name}`, which may result in it gaining all permissions associated with `${to_name}`.\",ACTION_NETWORK_PERMISSION_MESSAGE:\"Would you like to grant Action `${name}` network permissions?\",Return:\"Return\",Go:\"Go\",Google:\"Google\",Join:\"Join\",Next:\"Next\",Route:\"Route\",Search:\"Search\",Send:\"Send\",Yahoo:\"Yahoo\",Done:\"Done\",\"Emergency Call\":\"Emergency Call\",Continue:\"Continue\",Joining:\"Joining\",\"Route Continue\":\"Route Continue\"},\"zh-Hans\":{AUTHOR:\"作者\",ALERT_INFO:\"提示\",NONE:\"什么都没有\",DONE:\"完成\",CLOSE:\"关闭\",FAILED_TO_LOAD_VIEW:\"加载视图失败\",VIEW_NOT_PROVIDED:\"未提供该视图\",UNCATEGORIZED:\"未分类\",SHARE:\"分享\",CLICK_TO_OPEN_JSBOX:\"点击标题打开主应用。\",CLIPS:\"剪切板\",CLIPBOARD:\"剪切板\",UNIVERSAL_CLIPBOARD:\"通用剪贴板\",UNIVERSAL_CLIPBOARD_TIPS:\"用剪贴板允许您在 iPhone 上复制某些内容,然后使用 iCloud 将其粘贴到 Mac 上(反之亦然)。\",CLIPS_STRUCTURE_ERROR:\"剪切板数据结构异常\",CLIPBOARD_NO_CHANGE:\"剪切板无变化\",RECYCLE_BIN:\"回收站\",ADD:\"添加\",TAG:\"标签\",ADD_TAG:\"添加标签\",EDIT:\"编辑\",SEARCH:\"搜索\",SEARCH_HISTORY:\"搜索历史\",SEARCH_RESULT:\"搜索结果\",NO_SEARCH_RESULT:\"搜索无结果\",FAVORITE:\"收藏\",COPY:\"复制\",COPIED:\"已复制\",SORT:\"排序\",ACTIONS:\"动作\",MORE_ACTIONS:\"更多动作\",PREVIEW:\"预览\",MAX_ITEM_LENGTH:\"行数限制\",TEXT_MAX_LENGTH:\"显示字符长度\",AUTO_SAVE:\"自动保存\",AUTO_SYNC:\"自动同步\",SYNC_NOW:\"立即同步\",UNZIP_FAILED:\"解压文件失败\",REBUILD:\"重建\",REBUILD_DATABASE:\"重建数据库\",REBUILD_DATABASE_ALERT:\"重建数据库将会丢失顺序信息,是否确认重建?\",DELETE_ALL_DATA:\"删除所有数据\",DELETE_ALL_DATA_ALERT:\"确定要删除所有数据吗?\",DELETE_DATA:\"删除数据\",DELETE_TABLE:\"删除 `${table}` 的所有数据?\",SELECT_ALL:\"全选\",DESELECT_ALL:\"取消全选\",EDITOR:\"编辑器\",CREATE_NEW:\"新建\",CREATE_NEW_ACTION:\"新建动作\",CREATE_NEW_TYPE:\"新建分类\",TYPE_ALREADY_EXISTS:\"该类别已经存在\",EDIT_DETAILS:\"编辑信息\",EDIT_SCRIPT:\"编辑脚本\",INFORMATION:\"信息\",NAME:\"名称\",ICON:\"图标\",CATEGORY:\"分类\",EDIT_CATEGORY:\"编辑分类\",\"delete.category\":\"删除分类 ${category}\",\"delete.category.keep.actions\":\"是否保留该分类中的动作?\",DESCRIPTION:\"描述\",CODE:\"代码\",TEXT_INSETS:\"文本下边距\",SHOW_LINE_NUMBER:\"显示行号\",LIGHT_MODE_THEME:\"浅色模式主题\",DARK_MODE_THEME:\"深色模式主题\",SAVE:\"保存\",SAVE_SUCCESS:\"保存成功\",SAVE_ERROR:\"保存失败\",DELETE:\"删除\",CONFIRM:\"确认\",DELETE_CONFIRM_MSG:\"确认要删除吗?\",DELETE_SUCCESS:\"删除成功\",DELETE_ERROR:\"删除失败\",IMPORT_EXAMPLE_ACTIONS:\"导入示例动作\",REBUILD_ACTION_DATABASE:\"重建动作库\",REBUILD_ACTION_DATABASE_ALERT_TITLE:\"您确认要重建?\",REBUILD_ACTION_DATABASE_ALERT_MESSAGE:\"重建会同时删除保存在 WebDAV 中的数据!(如果开启的话)\",EXPORT:\"导出\",IMPORT:\"导入\",FILE_TYPE_ERROR:\"文件类型不符\",OVERWRITE_ALERT:\"该操作将会覆盖当前数据,是否继续?\",UNABLE_CREATE_ACTION:\"无法创建动作\",ACTION_NAME_ALREADY_EXISTS:\"动作 `${name}` 已存在\",IMPORT_FROM_FILE:\"从文件导入\",DEIT_CATEGORY:\"编辑分类\",KEYBOARD:\"键盘\",KEYBOARD_HEIGHT:\"键盘高度\",USE_BLUR:\"使用模糊效果\",BACKGROUND_IMAGE:\"背景图片\",DELETE_DELAY:\"删除延时\",SWITCH_AFTER_INSERT:\"输入后切换\",JSBOX_TOOLBAR:\"JSBox 工具栏\",QUICK_START_SCRIPTS:\"快速启动脚本\",SEND:\"发送\",OPEN_IN_JSBOX:\"在 JSBox 中打开\",SWITCH_KEYBOARD:\"切换键盘\",TAPTIC_ENGINE:\"触感反馈\",TAPTIC_ENGINE_LEVEL:\"触感反馈强度\",TAPTIC_ENGINE_FOR_DELETE:\"删除按钮触感反馈\",SPACE:\"空格\",ALL_SCRIPTS:\"所有脚本\",SELECT_SCRIPTS:\"选择脚本\",FONT_SIZE:\"字体大小\",LIST:\"列表\",MATRIX:\"网格\",PIN_ACTION:\"置顶动作\",CHECK_UPDATE:\"检查更新\",UPDATE:\"更新\",WIDGET:\"小组件\",RECENT:\"最近内容\",CLICK_ACTION:\"点击事件\",TODAY_WIDGET:\"通知中心小组件\",PREV_PAGE:\"上一页\",NEXT_PAGE:\"下一页\",DISPLAY_MODE:\"显示模式\",CLASSIC:\"经典\",MODERN:\"现代\",FILE_MANAGEMENT:\"文件管理\",\"compatibility.rebuildUserAction.alert.title\":\"我们需要重建部分动作!\",\"compatibility.rebuildUserAction.alert.message\":\"如果您点击 好,以下动作将会被重建:\",\"compatibility.rebuildUserAction.alert.message2\":\"只有动作逻辑会被更改,名称和图标将维持现状。\",EXPERIMENTAL:\"实验功能\",SYNC_ACTIONS:\"动作同步\",SYNCING:\"正在同步...\",LAST_SYNC_AT:\"最后同步:\",MODIFIED:\"最近修改:\",WEBDAV_ERROR_CLOSED:\"WebDAV 同步出错,暂时关闭。\",HOST:\"Host\",USER:\"User\",PASSWORD:\"Password\",BASEPATH:\"Base Path\",DATA_CONFLICT:\"数据同步发生冲突\",DATA_CONFLICT_MESSAGE:\"请选择想要保留的数据\",WEBDAV_DATA:\"WebDAV 数据\",LOCAL_DATA:\"本地数据\",ADD_TO_TAIO:\"添加到 Taio\",SELECT_TAIO_APP:\"请在分享菜单中选择 Taio App\",ACTION_SAFETY_WARNING:\"动作安全警告\",ACTION_PERMISSION_REQUEST:\"动作权限申请\",ACTION_RESET_NAME_WARNING:\"动作 `${name}` 正在尝试将名称改为 `${to_name}`,这可能导致其获取 `${to_name}` 的所有权限\",ACTION_NETWORK_PERMISSION_MESSAGE:\"是否允许动作 `${name}` 获取网络权限?\",Return:\"返回\",Go:\"前往\",Google:\"谷歌\",Join:\"加入\",Next:\"下一步\",Route:\"路线\",Search:\"搜索\",Send:\"发送\",Yahoo:\"雅虎\",Done:\"完成\",\"Emergency Call\":\"紧急呼叫\",Continue:\"继续\",Joining:\"正在加入\",\"Route Continue\":\"继续路线\"}},$app.theme=\"auto\",$app.minSDKVer=\"2.19.0\",$app.minOSVer=\"14.0.0\",$app.idleTimerDisabled=!1,$app.keyboardToolbarEnabled=!0,$app.rotateDisabled=!1,__INFO__={name:\"CAIO\",version:\"2.2.14\",author:\"ipuppet\",module:!1},__README__={\"README.md\":'# CAIO\\r\\n\\r\\n> Clipboard all in one. \\r\\n> An iOS clipboard tool based on JSBox.\\r\\n\\r\\n[See My Blog](https://blog.ultagic.com/#/detail/42/)\\r\\n\\r\\nSupport for home widgets and notification center widgets.\\r\\n\\r\\n## Build Taio Action\\r\\n\\r\\nThe build script depends on [Parcel](https://parceljs.org/).\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\nYou can also use the packaged files directly [dist/CAIO.json](./dist/CAIO.json).\\r\\n\\r\\n## Actions\\r\\n\\r\\n> For details on how to write, see `scripts/action/README.md` or the book button in the upper right corner of the `Action` edit page in the app.\\r\\n\\r\\n### `Action` data differences in different environments\\r\\n\\r\\n- The data processed by the `Action` button at the top of the home page is the currently copied content.\\r\\n- The data processed by the `Action` menu that pops up by long-pressing the list is the selected content.\\r\\n- The data processed by the `Action` button in the editor is whatever is being edited.\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> Click to copy, long press to trigger the action.\\r\\n\\r\\nPlease try to avoid using the Today Widget when JSBox is running CAIO.\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> Sync data with WebDAV.\\r\\n\\r\\nConfig Example: \\r\\nHost: `https://example.com/dav` \\r\\nUser: `guest` \\r\\nPassword: `password123` \\r\\nBase Path: `/path/to/save`\\r\\n\\r\\n## Shortcuts\\r\\n\\r\\nPlease add a new action called `Run JSBox script` and set the `Name` parameter to `CAIO`.\\r\\n\\r\\nNext, set the `Parameter Dictionary` to a `Dictionary`.\\r\\n\\r\\n| Parameter | Type |\\r\\n| --------- | ------ |\\r\\n| set | Text |\\r\\n| get | Number |\\r\\n| table | Text |\\r\\n\\r\\n- `set`: The content will be saved to CAIO unless there is already an existing item with the same name.\\r\\n- `get`: The item at the specified index (e.g., 0) will be returned.\\r\\n- `table`: It will specify the table to either set or get the item from, with options being `[\"favorite\", \"clips\"]`. This parameter is optional and has a default value of `clips`.\\r\\n',\"README_CN.md\":'# CAIO\\r\\n\\r\\n> Clipboard all in one. \\r\\n> An iOS clipboard tool based on JSBox.\\r\\n\\r\\n[查看我的博客](https://blog.ultagic.com/#/detail/42/)\\r\\n\\r\\n支持桌面小组件和通知中心小组件\\r\\n\\r\\n## 构建 Taio 动作\\r\\n\\r\\n构建脚本依赖 [Parcel](https://parceljs.org/)\\r\\n\\r\\n```shell\\r\\nnpm i -g parcel\\r\\nnpm run build\\r\\n```\\r\\n\\r\\n您也可以直接使用已打包好的文件 [dist/CAIO.json](./dist/CAIO.json)\\r\\n\\r\\n## Actions\\r\\n\\r\\n> 编写方式详见 `scripts/action/README.md` 或应用内 `Action` 编辑页面右上角图书按钮。\\r\\n\\r\\n### 不同环境中 `Action` 数据区别\\r\\n\\r\\n- 首页顶部 `Action` 按钮处理的数据为当前复制的内容\\r\\n- 长按列表弹出的 `Action` 菜单处理的数据为被选中的内容\\r\\n- 编辑器中顶部 `Action` 按钮(闪电图形按钮)处理的数据为正在编辑的所有内容\\r\\n\\r\\n## Today Widget\\r\\n\\r\\n> 点击复制,长按触发动作。\\r\\n\\r\\n请尽量避免在 JSBox 运行 CAIO 时使用 Today Widget\\r\\n\\r\\n## WebDAV\\r\\n\\r\\n> 通过 WebDAV 同步数据\\r\\n\\r\\n示例配置: \\r\\nHost: `https://example.com/dav` \\r\\nUser: `guest` \\r\\nPassword: `password123` \\r\\nBase Path: `/path/to/save`\\r\\n\\r\\n## 快捷指令\\r\\n\\r\\n添加一个名为 `运行 JSBox 脚本` 的动作,并将 `脚本名` 参数设置为 `CAIO`。\\r\\n\\r\\n然后将 `参数词典` 设置为一个 `字典`。\\r\\n\\r\\n| 参数 | 类型 |\\r\\n| ----- | ------ |\\r\\n| set | Text |\\r\\n| get | Number |\\r\\n| table | Text |\\r\\n\\r\\n- `set`:将把内容保存到CAIO中,除非已存在相同名称的项。\\r\\n- `get`:将返回指定索引(例如:0)处的项。\\r\\n- `table`:将指定要设置或获取项的表格,可选项为 `[\"favorite\", \"clips\"]`。此项可省略,默认值为 `clips`。\\r\\n'},__ACTIONS__={clipboard:{B23Clean:{config:'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"b23 清除追踪\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"b23clean.converting\": \"正在转换...\",\\n \"b23clean.noUrl\": \"未检测到链接\",\\n \"b23clean.noBiliUrl\": \"未检测到 bilibili 链接\",\\n \"b23clean.success\": \"已转换为 BV 视频链接\",\\n \"b23clean.noChange\": \"无变化\",\\n \"b23clean.multipleLinks\": \"多条链接仅在编辑模式下可用。\"\\n },\\n en: {\\n \"b23clean.converting\": \"Converting...\",\\n \"b23clean.noUrl\": \"No link detected\",\\n \"b23clean.noBiliUrl\": \"bilibili link not detected\",\\n \"b23clean.success\": \"Converted to BV video link\",\\n \"b23clean.noChange\": \"No change\",\\n \"b23clean.multipleLinks\": \"Multiple links are only available in edit mode.\"\\n }\\n }\\n }\\n\\n async cleanUrl(b23url) {\\n if (b23url.indexOf(\"bilibili.com\") === -1 && b23url.indexOf(\"b23.tv\") === -1) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n }\\n\\n let url = b23url\\n if (b23url.indexOf(\"b23.tv\") >= 0) {\\n const resp = await $http.get(b23url)\\n url = resp.response.url\\n }\\n\\n const queryStart = url.indexOf(\"?\")\\n if (queryStart > -1) {\\n url = url.substring(0, queryStart - 1)\\n }\\n\\n return url\\n }\\n\\n /**\\n * 系统会调用 do() 方法\\n */\\n async do() {\\n $ui.toast($l10n(\"b23clean.converting\"), 1000)\\n\\n try {\\n const b23url = this.getUrls()\\n if (b23url.length === 0) {\\n throw new Error($l10n(\"b23clean.noUrl\"))\\n }\\n\\n if (b23url.length === 1) {\\n let url = await this.cleanUrl(b23url[0])\\n $ui.clearToast()\\n $ui.alert({\\n title: $l10n(\"b23clean.success\"),\\n message: url,\\n actions: [\\n { title: $l10n(\"OK\") },\\n {\\n title: $l10n(\"COPY\"),\\n handler: () => {\\n $clipboard.text = url\\n $ui.success($l10n(\"COPIED\"))\\n }\\n }\\n ]\\n })\\n } else {\\n if (this.env !== ActionEnv.editor) {\\n $ui.toast($l10n(\"b23clean.multipleLinks\"))\\n return\\n }\\n let flag = false\\n for (let i = 0; i < b23url.length; i++) {\\n try {\\n const url = b23url[i].trim()\\n const replacedUrl = await this.cleanUrl(url)\\n flag = true\\n\\n if (url !== replacedUrl) {\\n const newText = this.text.replace(url, replacedUrl)\\n this.setContent(newText)\\n }\\n } catch {}\\n }\\n if (!flag) {\\n throw new Error($l10n(\"b23clean.noBiliUrl\"))\\n } else {\\n $ui.toast($l10n(\"b23clean.noChange\"))\\n }\\n }\\n } catch (error) {\\n $ui.clearToast()\\n $delay(0.5, () => $ui.error(error))\\n }\\n }\\n}\\n',readme:\"## B23Clean\\n\\n清除 b23.tv 分享链接中的追踪参数,转换为 BV 视频链接。\"},CleanClipboard:{config:'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"清除剪切板\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"clipboard.clean.success\": \"剪切板已清空\"\\n },\\n en: {\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\n }\\n }\\n }\\n\\n /**\\n * 系统会调用 do() 方法\\n */\\n do() {\\n $clipboard.clear()\\n $ui.success($l10n(\"clipboard.clean.success\"))\\n }\\n}\\n',readme:\"## CleanClipboard\\n\\n清空当前剪切板内容。\"},DownloadFromUrl:{config:'{\\n \"icon\": \"square.and.arrow.down\",\\n \"color\": \"#FF0099\",\\n \"name\": \"从链接下载\"\\n}',main:'class MyAction extends Action {\\n async downloadContent(url) {\\n const response = await $http.get({\\n url,\\n showsProgress: true\\n })\\n if (response.error) {\\n $ui.alert(response.error.localizedDescription)\\n } else {\\n return response\\n }\\n }\\n\\n async do() {\\n const url = this.getUrls()\\n let response = undefined\\n if (url.length > 1) {\\n $ui.menu({\\n items: url,\\n handler: async (title, index) => {\\n response = await this.downloadContent(url[index])\\n }\\n })\\n } else if (url.length === 1) {\\n response = await this.downloadContent(url[0])\\n } else {\\n $ui.warning(\"未检测到链接\")\\n return\\n }\\n $share.sheet([\\n {\\n name: response.response.suggestedFilename,\\n data: response.data\\n }\\n ])\\n return response\\n }\\n}\\n',readme:\"## DownloadFromUrl\\n\\n从链接下载内容,如 js 文件内容等。\"},GetFromWin:{config:'{\\n \"icon\": \"square.and.arrow.down\",\\n \"color\": \"#33CC33\",\\n \"name\": \"读取 clipsync\"\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"GET\")\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n $clipboard.text = resp.data.data\\r\\n if ($app.env === $env.keyboard) {\\r\\n $keyboard.insert(resp.data.data)\\r\\n }\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## GetFromWin\\n\\n通 clipsync 读取 PC 剪切板。\\n\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\n\"},OpenUrl:{config:'{\\n \"icon\": \"link\",\\n \"color\": \"#FF0099\",\\n \"name\": \"打开链接\"\\n}',main:'class MyAction extends Action {\\n l10n() {\\n return {\\n \"zh-Hans\": {\\n \"openLink.nourl\": \"未检测到链接\"\\n },\\n en: {\\n \"openLink.nourl\": \"No link detected\"\\n }\\n }\\n }\\n\\n openUrl(url) {\\n $app.openURL(url.trim())\\n }\\n\\n do() {\\n const url = this.getUrls()\\n if (url.length > 1) {\\n $ui.menu({\\n items: url,\\n handler: (title, index) => {\\n this.openUrl(url[index])\\n }\\n })\\n } else if (url.length === 1) {\\n this.openUrl(url[0])\\n } else {\\n $ui.warning($l10n(\"openLink.nourl\"))\\n }\\n }\\n}\\n',readme:\"## OpenUrl\\n\\n提取文本中的URL并打开。\"},RawRepoConverter:{config:'{\\r\\n \"icon\": \"link\",\\r\\n \"color\": \"#FF0099\",\\r\\n \"name\": \"RawRepoConverter\"\\r\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n #component\\r\\n\\r\\n get component() {\\r\\n if (!this.#component) {\\r\\n const url = String(this.text)\\r\\n const path = url.substring(url.indexOf(\"/\", \"https://\".length) + 1)\\r\\n this.#component = path.split(\"/\")\\r\\n }\\r\\n return this.#component\\r\\n }\\r\\n\\r\\n l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"openLink.nourl\": \"未检测到链接\"\\r\\n },\\r\\n en: {\\r\\n \"openLink.nourl\": \"No link detected\"\\r\\n }\\r\\n }\\r\\n }\\r\\n\\r\\n githubusercontent() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n branch = this.component[2],\\r\\n file = this.component.slice(3).join(\"/\")\\r\\n return `https://github.com/${user}/${repository}/blob/${branch}/${file}`\\r\\n }\\r\\n\\r\\n github() {\\r\\n const user = this.component[0],\\r\\n repository = this.component[1],\\r\\n blob = this.component[2],\\r\\n branch = this.component[3],\\r\\n file = this.component.slice(4).join(\"/\")\\r\\n return `https://raw.githubusercontent.com/${user}/${repository}/${branch}/${file}`\\r\\n }\\r\\n\\r\\n do() {\\r\\n let result\\r\\n const url = String(this.text)\\r\\n if (url.includes(\"raw.githubusercontent.com\")) {\\r\\n result = this.githubusercontent(url)\\r\\n } else if (url.includes(\"github.com\")) {\\r\\n if (url.includes(\"?raw=true\")) {\\r\\n result = url.replace(\"?raw=true\", \"\")\\r\\n } else {\\r\\n result = this.github()\\r\\n }\\r\\n } else {\\r\\n $ui.warning($l10n(\"openLink.nourl\"))\\r\\n return\\r\\n }\\r\\n\\r\\n $ui.success($l10n(\"COPIED\"))\\r\\n $clipboard.text = result\\r\\n }\\r\\n}\\r\\n',readme:\"## RawRepoConverter\\r\\n\\r\\nGithub Raw 链接和 Repository 链接转换器\\r\\n\"},SendToWin:{config:'{\\n \"icon\": \"square.and.arrow.up\",\\n \"color\": \"#33CC33\",\\n \"name\": \"推送 clipsync\"\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n async getIp(refresh = false) {\\r\\n let address = $cache.get(\"caio.action.clipsync.address\")\\r\\n if (refresh || !address) {\\r\\n address = await $input.text({\\r\\n placeholder: \"Address\",\\r\\n text: $cache.get(\"caio.action.clipsync.address\")\\r\\n })\\r\\n }\\r\\n\\r\\n $cache.set(\"caio.action.clipsync.address\", address)\\r\\n\\r\\n if (!address.startsWith(\"http\")) {\\r\\n address = \"http://\" + address\\r\\n }\\r\\n\\r\\n return address\\r\\n }\\r\\n\\r\\n async do() {\\r\\n let address = await this.getIp()\\r\\n\\r\\n $ui.toast(\"Loading...\", 5)\\r\\n try {\\r\\n const resp = await this.request(address + \"/api/clip\", \"POST\", {\\r\\n data: this.text ?? $clipboard.text\\r\\n })\\r\\n if (resp.data.status) {\\r\\n $ui.success(\"success\")\\r\\n }\\r\\n } catch (error) {\\r\\n $ui.clearToast()\\r\\n $ui.alert({\\r\\n title: \"Error\",\\r\\n message: String(error),\\r\\n actions: [\\r\\n { title: \"OK\" },\\r\\n {\\r\\n title: \"Reset Adress\",\\r\\n handler: () => this.getIp(true)\\r\\n }\\r\\n ]\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## SendToWin\\n\\n通 clipsync 推送剪切板至 PC。\\n\\n服务端:[clipsync](https://github.com/ipuppet/clipsync)\\n\"},Tokenize:{config:'{\\n \"icon\": \"pencil.and.ellipsis.rectangle\",\\n \"color\": \"#0099FF\",\\n \"name\": \"分词复制\"\\n}',main:'class MyAction extends Action {\\n getView() {\\n const color = {\\n background: {\\n normal: $color(\"#E7F2FF\", \"#E7F2FF\"),\\n highlight: $color(\"##074FF\", \"#BBDAFF\")\\n },\\n text: {\\n normal: $color(\"##074FF\", \"##074FF\"),\\n highlight: $color(\"#FFFFFF\", \"#ADADAD\")\\n }\\n }\\n const fontSize = 16\\n const edges = 10\\n return {\\n type: \"matrix\",\\n layout: $layout.fill,\\n props: {\\n spacing: edges,\\n data: this.results.map(item => ({ label: { text: item } })),\\n template: {\\n views: [{\\n type: \"label\",\\n props: {\\n id: \"label\",\\n align: $align.center,\\n cornerRadius: edges,\\n bgcolor: color.background.normal,\\n font: $font(fontSize),\\n textColor: color.text.normal\\n },\\n layout: $layout.fill\\n }]\\n }\\n },\\n events: {\\n highlighted: () => { },\\n itemSize: (sender, indexPath) => {\\n const width = fontSize * this.results[indexPath.item].length + 1\\n if (this.maxtrixItemHeight === undefined)\\n this.maxtrixItemHeight = fontSize + edges * 2\\n return $size(width + edges * 2, this.maxtrixItemHeight)\\n },\\n didSelect: (sender, indexPath) => {\\n const index = this.selected.indexOf(indexPath.item)\\n const label = sender.cell(indexPath).get(\"label\")\\n if (index === -1) {\\n this.selected.push(indexPath.item)\\n label.bgcolor = color.background.highlight\\n label.textColor = color.text.highlight\\n } else {\\n this.selected.splice(index, 1)\\n label.bgcolor = color.background.normal\\n label.textColor = color.text.normal\\n }\\n }\\n }\\n }\\n }\\n /**\\n * 系统会调用 do() 方法\\n */\\n do() {\\n this.selected = []\\n this.results = []\\n $text.tokenize({\\n text: this.text,\\n handler: results => {\\n this.results = results\\n this.pageSheet({\\n view: this.getView(),\\n done: () => {\\n const result = []\\n this.selected.sort().forEach(i => {\\n result.push(this.results[i])\\n })\\n if (result.length > 0) {\\n const text = result.join(\"\")\\n $clipboard.text = text\\n $ui.alert({\\n title: \"完成\",\\n message: `已复制内容:${text}`\\n })\\n }\\n }\\n })\\n }\\n })\\n }\\n}\\n',readme:\"## Tokenize\\n\\n将文本分词处理后复制。\"}},editor:{Paste:{config:'{\\n \"icon\": \"doc.on.clipboard\",\\n \"color\": \"#FF0000\",\\n \"name\": \"Paste\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\nclass MyAction extends Action {\\n do() {\\n const text = $clipboard.text\\n if (!text || text === \"\") return\\n $keyboard.insert(text)\\n }\\n}\\n',readme:\"## Paste\\n\\n向输入框输入剪切板内的内容\"},PreviewMarkdown:{config:'{\\n \"icon\": \"book\",\\n \"color\": \"#9900CC\",\\n \"name\": \"预览Markdown\"\\n}',main:'class MyAction extends Action {\\n do() {\\n this.pageSheet({\\n view: {\\n type: \"markdown\",\\n props: { content: this.text },\\n layout: $layout.fill\\n }\\n })\\n }\\n}\\n',readme:\"## PreviewMarkdown\\n\\n预览Markdown。\"},Replace:{config:'{\\n \"icon\": \"square.and.arrow.up\",\\n \"color\": \"#FF3300\",\\n \"name\": \"查找替换\"\\n}',main:'function HtmlTemplate(html) {\\r\\n return `\\r\\n\\r\\n\\r\\n \\r\\n\\r\\n\\r\\n${html}\\r\\n\\r\\n\\r\\n`\\r\\n}\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n $ui.menu({\\r\\n items: [\"忽略大小写\", \"大小写敏感\", \"正则表达式\"],\\r\\n handler: async (title, idx) => {\\r\\n const patternText = await $input.text({\\r\\n placeholder: \"查找内容\"\\r\\n })\\r\\n const replaceString = await $input.text({\\r\\n placeholder: \"替换内容\"\\r\\n })\\r\\n let pattern = undefined\\r\\n if (idx === 0) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"gi\")\\r\\n } else if (idx === 1) {\\r\\n pattern = new RegExp(`(${patternText})+`, \"g\")\\r\\n } else if (idx === 2) {\\r\\n pattern = new RegExp(patternText, \"g\")\\r\\n }\\r\\n\\r\\n const matchResultPreview = this.text.replaceAll(pattern, `${replaceString}`)\\r\\n const matchResult = this.text.replaceAll(pattern, replaceString)\\r\\n this.pageSheet({\\r\\n title: \"替换预览\",\\r\\n doneText: \"替换\",\\r\\n view: {\\r\\n type: \"web\",\\r\\n props: {\\r\\n html: HtmlTemplate(matchResultPreview)\\r\\n },\\r\\n layout: $layout.fill\\r\\n },\\r\\n done: () => {\\r\\n this.setContent(matchResult)\\r\\n }\\r\\n })\\r\\n }\\r\\n })\\r\\n // this.setContent(\"Hello world!\")\\r\\n }\\r\\n}\\r\\n',readme:\"## Replace\\n\\n查找替换\"},SelectedText:{config:'{\\n \"icon\": \"crop\",\\n \"color\": \"#6699CC\",\\n \"name\": \"选中的文本\"\\n}',main:\"class MyAction extends Action {\\n do() {\\n if (this.selectedRange.length > 0) {\\n const selectedText = this.text\\n $ui.alert(selectedText)\\n }\\n }\\n}\\n\",readme:\"## SelectedText\\n\\n显示选中的文本。\"}},uncategorized:{ActionEditPreview:{config:'{\\r\\n \"icon\": \"play\",\\r\\n \"color\": \"#FF0000\",\\r\\n \"name\": \"编辑动作即时预览示例\"\\r\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n * @typedef {import(\"../../action\").ActionData} ActionData\\r\\n * @typedef {import(\"../../action\").ActionEnv} ActionEnv\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n preview() {\\r\\n return new ActionData({\\r\\n text: \"hello word\"\\r\\n })\\r\\n }\\r\\n\\r\\n async do() {\\r\\n try {\\r\\n if (this.env !== ActionEnv.build) {\\r\\n $ui.toast(\"action editor only\")\\r\\n return\\r\\n }\\r\\n return this.text\\r\\n } catch (error) {\\r\\n $ui.alert(error)\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## ActionEditPreview\\r\\n\\r\\n编辑动作即时预览示例。\"},DeleteClips:{config:'{\\n \"icon\": \"trash\",\\n \"color\": \"#FF0000\",\\n \"name\": \"删除所有剪切板\"\\n}',main:'/**\\n * @typedef {import(\"../../action\").Action} Action\\n */\\n\\nclass MyAction extends Action {\\n async do() {\\n try {\\n const action = await this.clearAllClips()\\n if (action) {\\n $ui.success($l10n(\"DONE\"))\\n }\\n } catch (error) {\\n $ui.error(error)\\n }\\n }\\n}\\n',readme:\"## DeleteClips\\n\\n删除所有已保存的剪切板(不包括收藏)。\"},DisplayClipboard:{config:'{\\n \"icon\": \"option\",\\n \"color\": \"#FF6633\",\\n \"name\": \"显示剪切板\"\\n}',main:'/**\\r\\n * @typedef {import(\"../../action\").Action} Action\\r\\n */\\r\\n\\r\\nclass MyAction extends Action {\\r\\n do() {\\r\\n const image = $clipboard.image\\r\\n if (image) {\\r\\n this.quickLookImage(image)\\r\\n } else {\\r\\n this.pageSheet({\\r\\n view: {\\r\\n type: \"text\",\\r\\n props: {\\r\\n editable: false,\\r\\n text: $clipboard.text,\\r\\n insets: $insets(10, 10, 10, 10)\\r\\n },\\r\\n layout: $layout.fill\\r\\n }\\r\\n })\\r\\n }\\r\\n }\\r\\n}\\r\\n',readme:\"## DisplayClipboard\\n\\n显示当前剪切板内的内容。\"},ExportAllContent:{config:'{\\n \"icon\": \"square.and.arrow.up\",\\n \"color\": \"#FF3300\",\\n \"name\": \"导出数据\"\\n}',main:'class MyAction extends Action {\\n do() {\\n const data = this.getAllClips()\\n if (data.clips.length > 0 || data.favorite.length > 0) {\\n $share.sheet(JSON.stringify(data, null, 2))\\n } else {\\n $ui.alert(\"无数据\")\\n }\\n }\\n}\\n',readme:\"## ExportAllContent\\n\\n导出所有保存的数据。\"}}},__ACTION_README__={content:'# Action\\r\\n\\r\\n所有 Action 保存在 `storage/user_action` 目录下,按照文件夹分类\\r\\n\\r\\n`Action` 结构如下:\\r\\n\\r\\n- `ActionName`\\r\\n - `config.json` 配置文件\\r\\n - `main.js` 入口文件\\r\\n - `README.md` 说明文件\\r\\n\\r\\n### `config.json` 配置项\\r\\n\\r\\n- `icon` 图标 可以是 [JSBox 内置图标](https://github.com/cyanzhong/xTeko/tree/master/extension-icons)、SF Symbols图标、base64图片数据和来自 url 的图片\\r\\n- `color` 颜色\\r\\n- `name` 名称\\r\\n- `description` 描述信息\\r\\n\\r\\n### `main.js` 入口文件\\r\\n\\r\\n创建名为 `MyAction` 的类并继承 `Action` 类\\r\\n\\r\\n```js\\r\\n/**\\r\\n * @typedef {import(\"scripts/action/action.js\").Action} Action\\r\\n */\\r\\n/**\\r\\n * 必须为 MyAction\\r\\n */\\r\\nclass MyAction extends Action {\\r\\n /**\\r\\n * 系统会调用 do() 方法\\r\\n * 在编辑模式如果提供了返回值,则可弹窗预览返回值\\r\\n */\\r\\n do() {\\r\\n console.log(this.text)\\r\\n }\\r\\n}\\r\\n```\\r\\n\\r\\n### 父类 `Action` 的属性:\\r\\n- `this.env` \\r\\n 当前运行环境,参见 [ActionEnv](#ActionEnv)\\r\\n- `this.config` \\r\\n 当前 Action 配置文件内容\\r\\n- `this.originalContent` \\r\\n 原始数据\\r\\n- `this.text` \\r\\n 优先为选中的文本,若无则:当处于键盘中运行时为输入框内文本,处于编辑器时为编辑器内文本,其他情况为剪切板内文本\\r\\n- `this.selectedRange` \\r\\n 在编辑器中,当前选中的文本范围 `{location: Number, length: Number}`\\r\\n\\r\\n更多参见 [ActionData](#ActionData)\\r\\n\\r\\n### 父类的方法:\\r\\n```js\\r\\n/**\\r\\n * 编辑动作状态下提供预览数据\\r\\n * @returns {ActionData}\\r\\n */\\r\\npreview(): ActionData\\r\\n\\r\\n/**\\r\\n * 重写该方法返回 l10n 对象可注入 l10n\\r\\n * l10n() {\\r\\n return {\\r\\n \"zh-Hans\": {\\r\\n \"clipboard.clean.success\": \"剪切板已清空\"\\r\\n },\\r\\n en: {\\r\\n \"clipboard.clean.success\": \"Clipboard is cleaned\"\\r\\n }\\r\\n }\\r\\n }\\r\\n */\\r\\nl10n()\\r\\n\\r\\n/**\\r\\n * page sheet\\r\\n * @param {*} args \\r\\n * {\\r\\n view: args.view, // 视图对象\\r\\n title: args.title ?? \"\", // 中间标题\\r\\n done: args.done, // 点击左上角按钮后的回调函数\\r\\n doneText: args.doneText ?? $l10n(\"DONE\") // 左上角文本\\r\\n rightButtons: [{ title:string, symbol:string, tapped:function }] // 右上角按钮\\r\\n }\\r\\n */\\r\\npageSheet(args): void\\r\\n\\r\\n/**\\r\\n * 获取所有剪切板数据\\r\\n * @returns {object}\\r\\n */\\r\\ngetAllClips(): { favorite, clips }\\r\\n\\r\\n/**\\r\\n * 更新当前文本,当用户侧滑返回时才会触发保存操作\\r\\n */\\r\\nsetContent(text): void\\r\\n\\r\\n/**\\r\\n * 获取指定的 Action 类\\r\\n * @param {string} category\\r\\n * @param {string} name config.name\\r\\n * @param {ActionData} data new ActionData({ args: any })\\r\\n * @returns\\r\\n */\\r\\ngetAction(category, name, data): any\\r\\n\\r\\n/**\\r\\n * 运行指定的 Action 并返回该 Action do() 方法的返回值\\r\\n */\\r\\nasync runAction(category, name): any\\r\\n\\r\\n/**\\r\\n * 从 `this.text` 中匹配所有 url\\r\\n */\\r\\ngetUrls(): []\\r\\n\\r\\n/**\\r\\n * 运行其他 JSBox 脚本\\r\\n * @param {string} name\\r\\n */\\r\\naddinRun(name): void\\r\\n```\\r\\n\\r\\n### ActionEnv\\r\\n```js\\r\\nclass ActionEnv {\\r\\n static build = -1 // 动作编辑器\\r\\n static today = 0\\r\\n static editor = 1\\r\\n static clipboard = 2\\r\\n static action = 3\\r\\n static keyboard = 4\\r\\n}\\r\\n```\\r\\n\\r\\n### ActionData\\r\\n```js\\r\\nclass ActionData {\\r\\n env\\r\\n args // 其他动作传递的参数\\r\\n text // 自动获取文本,优先获取选中的文本\\r\\n allText // 获取所有文本\\r\\n section // 首页剪切板分类\\r\\n uuid // 首页剪切板项目 uuid\\r\\n selectedRange // 文本选中的范围\\r\\n selectedText // 选中的文本\\r\\n textBeforeInput // 键盘中输入光标之前的文本\\r\\n textAfterInput // 键盘中输入光标之后的文本\\r\\n editor // 编辑器\\r\\n}\\r\\n```\\r\\n\\r\\n其中 `editor` 如下:\\r\\n\\r\\n```js\\r\\nconst editor = {\\r\\n originalContent,\\r\\n setContent: text => {}\\r\\n}\\r\\n```\\r\\n'},$app.env){case $env.app:case $env.action:t=n(\"6olY1\");break;case $env.today:case $env.keyboard:case $env.siri:t=n(\"ljE8b\");break;case $env.widget:t=n(\"gD12U\");break;default:$intents.finish(\"不支持在此环境中运行\"),$ui.render({views:[{type:\"label\",props:{text:\"不支持在此环境中运行\",align:$align.center},layout:$layout.fill}]})}t&&t.run()})();" } } } diff --git a/main.js b/main.js index 37386f3b..adb25a6b 100644 --- a/main.js +++ b/main.js @@ -31,7 +31,7 @@ switch ($app.env) { break } -// AppInstance = require("./scripts/widget") +//AppInstance = require("./scripts/widget") if (AppInstance) { AppInstance.run() } diff --git a/scripts/app.js b/scripts/app.js index 018a08cf..2de29e2d 100644 --- a/scripts/app.js +++ b/scripts/app.js @@ -20,7 +20,7 @@ class AppKernelBase extends Kernel { constructor() { super() - $file.list($file.rootPath) + // $file.list($file.rootPath) $app.listen({ exit: () => $objc_clean() }) // FileStorage this.fileStorage = AppKernelBase.fileStorage diff --git a/scripts/setting/setting-methods.js b/scripts/setting/setting-methods.js index 132e9993..15fb5425 100644 --- a/scripts/setting/setting-methods.js +++ b/scripts/setting/setting-methods.js @@ -442,8 +442,7 @@ function settingMethods(appKernel) { animate.done() } - kernel.setting.method.previewWidget = animate => { - const { Widget } = require("../widget") + kernel.setting.method.previewWidget = () => { const widgets = {} try { JSON.parse($file.read("widget-options.json").string).forEach(item => { @@ -456,6 +455,7 @@ function settingMethods(appKernel) { $ui.menu({ items: Object.keys(widgets), handler: name => { + const { Widget } = require("../widget") Widget.render(widgets[name]) } }) diff --git a/scripts/ui/clips/clips.js b/scripts/ui/clips/clips.js index ad66a881..6a33bb18 100644 --- a/scripts/ui/clips/clips.js +++ b/scripts/ui/clips/clips.js @@ -43,6 +43,8 @@ class Clips extends ClipsData { if (UIKit.isTaio) return $app.listen({ resume: () => { + // 重载小组件 + $widget.reloadTimeline() // 在应用恢复响应后调用 if (!this.needReload && $(this.views.listId).ocValue().$isEditing()) { return @@ -79,6 +81,34 @@ class Clips extends ClipsData { this.delegates.setDelegate() } + async checkUrlScheme() { + // actions widget + if ($context.query["runAction"]) { + const data = JSON.parse($text.base64Decode($context.query["runAction"])) + const action = this.kernel.actions.getAction( + data.category, + data.dir, + new ActionData({ env: ActionEnv.widget }) + ) + action.do() + return + } + // clips widget + if ($context.query["copy"]) { + const uuid = $context.query["copy"] + this.setCopied(uuid) + $ui.success($l10n("COPIED")) + } else if ($context.query["add"]) { + this.getAddTextView() + } else if ($context.query["actions"]) { + if (this.kernel.isUseJsboxNav) { + this.kernel.actions.present() + } else { + this.kernel.tabBarController.switchPageTo("actions") + } + } + } + /** * list view ready event */ @@ -95,31 +125,7 @@ class Clips extends ClipsData { if (UIKit.isTaio) return // check url scheme - $delay(0.5, () => { - if ($context.query["copy"]) { - const uuid = $context.query["copy"] - this.setCopied(uuid) - $ui.success($l10n("COPIED")) - } else if ($context.query["add"]) { - this.getAddTextView() - } else if ($context.query["actions"]) { - if (this.kernel.isUseJsboxNav) { - this.kernel.actions.present() - } else { - this.kernel.tabBarController.switchPageTo("actions") - } - } else if ($context.query["runAction"]) { - $delay(0, () => { - const data = JSON.parse($text.base64Decode($context.query["runAction"])) - const action = this.kernel.actions.getAction( - data.category, - data.dir, - new ActionData({ env: ActionEnv.widget }) - ) - action.do() - }) - } - }) + $delay(0, () => this.checkUrlScheme()) this.appListen() } diff --git a/scripts/widget.js b/scripts/widget.js index d71713c2..9f5b7cdd 100644 --- a/scripts/widget.js +++ b/scripts/widget.js @@ -1,16 +1,14 @@ -const { Logger } = require("./libs/easy-jsbox") const { AppKernelBase } = require("./app") /** * @typedef {AppKernel} AppKernel */ class AppKernel extends AppKernelBase { + logFile = "widget.log" + constructor() { super() - this.logger = new Logger() - this.logger.printToFile(this.fileStorage, "logs/widget.log") - this.setting.setReadonly() } diff --git a/scripts/widget/Actions.js b/scripts/widget/Actions.js index aec8dec8..7edea066 100644 --- a/scripts/widget/Actions.js +++ b/scripts/widget/Actions.js @@ -74,9 +74,10 @@ class ActionsWidget { return { type: "vstack", props: { + background: $color("primarySurface"), alignment: $widget.horizontalAlignment.leading, spacing: 0, - padding: 10, + padding: 20, widgetURL: this.getUrlScheme(action) }, views: [ @@ -100,7 +101,10 @@ class ActionsWidget { } }, { - cornerRadius: 10 + cornerRadius: { + value: 15, + style: 1 + } } ], views: [ @@ -152,9 +156,12 @@ class ActionsWidget { const height = this.ctx.displaySize.height const width = this.ctx.displaySize.width - const padding = 28 - const itemHeight = (height - padding * (this.maxLength / 2 + 1)) / (this.maxLength / 2) - const itemWidth = (width - padding * 3) / 2 + const padding = 25 + const innerPadding = 5 + const itemHeight = (height - padding * (this.maxLength / 2 + 1)) / (this.maxLength / 2) - innerPadding * 2 + const itemWidth = (width - padding * 3) / 2 - innerPadding * 2 + const r_outer = 15 + const r_inner = r_outer * ((itemHeight - 2 * innerPadding) / itemHeight) for (let i = 0; i < length; i += 2) { const row = [] for (let j = 0; j < 2; j++) { @@ -163,14 +170,29 @@ class ActionsWidget { type: "hstack", props: { spacing: 0, - padding: 0, - link: this.getUrlScheme(action), - frame: { - maxWidth: itemWidth, - maxHeight: itemHeight, - alignment: $widget.alignment.leading - } + link: this.getUrlScheme(action) }, + modifiers: [ + { + background: $color({ + light: $rgb(245, 245, 245), + dark: $rgba(80, 80, 80, 0.3), + black: $rgba(70, 70, 70, 0.3) + }), + padding: innerPadding, + frame: { + maxWidth: itemWidth, + maxHeight: itemHeight, + alignment: $widget.alignment.leading + } + }, + { + cornerRadius: { + value: r_outer, + style: 1 + } + } + ], views: [ { type: "hstack", @@ -178,15 +200,18 @@ class ActionsWidget { { background: $color(action.color), frame: { - width: itemHeight - 5, - height: itemHeight - 5 + width: itemHeight, + height: itemHeight } }, { - cornerRadius: 10 + cornerRadius: { + value: r_inner, + style: 1 + } } ], - views: [this.getIcon(action, (itemHeight - 5) * 0.6)] + views: [this.getIcon(action, itemHeight * 0.6)] }, { type: "spacer", @@ -216,6 +241,7 @@ class ActionsWidget { return { type: "vstack", props: { + background: $color("primarySurface"), spacing: padding, padding: padding }, diff --git a/scripts/widget/list-widget.js b/scripts/widget/list-widget.js index 6e25bd4f..e73f1bf5 100644 --- a/scripts/widget/list-widget.js +++ b/scripts/widget/list-widget.js @@ -50,6 +50,7 @@ class ListWidget { return { type: "vstack", props: { + background: $color("primarySurface"), alignment: $widget.horizontalAlignment.leading, spacing: 0, padding: this.padding, @@ -141,6 +142,7 @@ class ListWidget { return { type: "hstack", props: { + background: $color("primarySurface"), spacing: 0, padding: this.padding, widgetURL: this.urlScheme.clips